Drag and Drop File Name from Windows Explorer into Access Form Textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Drag and Drop File Name from Windows Explorer into Access Form Textbox

    I am looking for VBA code that will work with Access 2003 to enable
    dragging and dropping a file/folder name from Windows XP Explorer into
    an Access form's text box. This is a common functionality that most
    Windows programs have, so I'm suprised it's not easier to implement in
    Access/VBA.

    Through Google, I found two VB6 examples and one VBA example on the
    Access Web written by Dev Ashish. The VB6 examples used loops to keep
    checking for the drag-drop Windows event and prevented my form from
    loading. Dev's code looked much better, but it didn't work in Accesss
    2003. It looks like it was written prior to Access 2000. The link to
    Dev's code is here:

    I successfully use many other API calls in my project, but trying to
    debug Dev's code is way over my head.

    Dev's code refers to a class module named "AddrOf" that is available
    here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
    However, this module has errors under Access 2003 when it runs, one of
    which says a DLL file is missing.

    VBA under Access 2003 has a built-in function, "AddressOf" , that
    should accomplish the same thing as the older "AddrOf" class module,
    but I can't seem to get it to work. When I try using the "AddressOf"
    function in Dev's code, it compiles fine, but when it runs, Access
    2003 crashes back to the desktop.

    If anyone has VBA code that will allow dragging and dropping
    file/folder names from Windows explorer into a form's textbox/listbox,
    would you please be kind enough to provide me with the code, or a link
    to the code.

    Thanks !
  • Tom van Stiphout

    #2
    Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

    On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@ya hoo.com>
    wrote:

    A2000 and above have the AddressOf operator.
    Follow Dev's example to the letter. Then replace the sHook function
    with this code:
    Sub sHook(Hwnd As Long, _
    strFunction As String)
    'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
    AddrOf(strFunct ion))
    Select Case strFunction
    Case "sDragDrop"
    lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
    AddressOf sDragDrop)
    Case Else
    Debug.Assert False 'Need to setup this function as
    another Case.
    End Select
    End Sub

    Works for me in A2007.
    Happy dropping,

    -Tom.


    >I am looking for VBA code that will work with Access 2003 to enable
    >dragging and dropping a file/folder name from Windows XP Explorer into
    >an Access form's text box. This is a common functionality that most
    >Windows programs have, so I'm suprised it's not easier to implement in
    >Access/VBA.
    >
    >Through Google, I found two VB6 examples and one VBA example on the
    >Access Web written by Dev Ashish. The VB6 examples used loops to keep
    >checking for the drag-drop Windows event and prevented my form from
    >loading. Dev's code looked much better, but it didn't work in Accesss
    >2003. It looks like it was written prior to Access 2000. The link to
    >Dev's code is here:
    >http://www.mvps.org/access/api/api0032.htm
    >I successfully use many other API calls in my project, but trying to
    >debug Dev's code is way over my head.
    >
    >Dev's code refers to a class module named "AddrOf" that is available
    >here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
    >However, this module has errors under Access 2003 when it runs, one of
    >which says a DLL file is missing.
    >
    >VBA under Access 2003 has a built-in function, "AddressOf" , that
    >should accomplish the same thing as the older "AddrOf" class module,
    >but I can't seem to get it to work. When I try using the "AddressOf"
    >function in Dev's code, it compiles fine, but when it runs, Access
    >2003 crashes back to the desktop.
    >
    >If anyone has VBA code that will allow dragging and dropping
    >file/folder names from Windows explorer into a form's textbox/listbox,
    >would you please be kind enough to provide me with the code, or a link
    >to the code.
    >
    >Thanks !

    Comment

    • Tom van Stiphout

      #3
      Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

      On Wed, 30 Apr 2008 21:40:18 -0700, Tom van Stiphout
      <no.spam.tom774 4@cox.netwrote:

      I should have said: Follow Dev's example to the letter, except the
      part of getting the AddrOf code from trigeminal.com.

      -Tom.


      >On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@ya hoo.com>
      >wrote:
      >
      >A2000 and above have the AddressOf operator.
      >Follow Dev's example to the letter. Then replace the sHook function
      >with this code:
      >Sub sHook(Hwnd As Long, _
      strFunction As String)
      'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
      >AddrOf(strFunc tion))
      Select Case strFunction
      Case "sDragDrop"
      lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
      >AddressOf sDragDrop)
      Case Else
      Debug.Assert False 'Need to setup this function as
      >another Case.
      End Select
      >End Sub
      >
      >Works for me in A2007.
      >Happy dropping,
      >
      >-Tom.
      >
      >
      >
      >>I am looking for VBA code that will work with Access 2003 to enable
      >>dragging and dropping a file/folder name from Windows XP Explorer into
      >>an Access form's text box. This is a common functionality that most
      >>Windows programs have, so I'm suprised it's not easier to implement in
      >>Access/VBA.
      >>
      >>Through Google, I found two VB6 examples and one VBA example on the
      >>Access Web written by Dev Ashish. The VB6 examples used loops to keep
      >>checking for the drag-drop Windows event and prevented my form from
      >>loading. Dev's code looked much better, but it didn't work in Accesss
      >>2003. It looks like it was written prior to Access 2000. The link to
      >>Dev's code is here:
      >>http://www.mvps.org/access/api/api0032.htm
      >>I successfully use many other API calls in my project, but trying to
      >>debug Dev's code is way over my head.
      >>
      >>Dev's code refers to a class module named "AddrOf" that is available
      >>here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
      >>However, this module has errors under Access 2003 when it runs, one of
      >>which says a DLL file is missing.
      >>
      >>VBA under Access 2003 has a built-in function, "AddressOf" , that
      >>should accomplish the same thing as the older "AddrOf" class module,
      >>but I can't seem to get it to work. When I try using the "AddressOf"
      >>function in Dev's code, it compiles fine, but when it runs, Access
      >>2003 crashes back to the desktop.
      >>
      >>If anyone has VBA code that will allow dragging and dropping
      >>file/folder names from Windows explorer into a form's textbox/listbox,
      >>would you please be kind enough to provide me with the code, or a link
      >>to the code.
      >>
      >>Thanks !

      Comment

      • biganthony via AccessMonster.com

        #4
        Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

        Hello Tom,

        I saw this thread, was interested in it and decided to try it out but I
        receive the following error message when I compile the module: "Invalid Use
        of AddressOfOperat or" on the line below:

        lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC, AddressOf sDragDrop)

        I have copied the code from the Access Web site, substituted in your module,
        created the form and placed the listbox on it.

        I am using Access 2003 SP2.

        Regards
        Anthony



        Tom van Stiphout wrote:
        >A2000 and above have the AddressOf operator.
        >Follow Dev's example to the letter. Then replace the sHook function
        >with this code:
        >Sub sHook(Hwnd As Long, _
        strFunction As String)
        'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
        >AddrOf(strFunc tion))
        Select Case strFunction
        Case "sDragDrop"
        lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
        >AddressOf sDragDrop)
        Case Else
        Debug.Assert False 'Need to setup this function as
        >another Case.
        End Select
        >End Sub
        >
        >Works for me in A2007.
        >Happy dropping,
        >
        >-Tom.
        >
        >>I am looking for VBA code that will work with Access 2003 to enable
        >>dragging and dropping a file/folder name from Windows XP Explorer into
        >[quoted text clipped - 29 lines]
        >>
        >>Thanks !
        --
        Message posted via AccessMonster.c om


        Comment

        • Tom van Stiphout

          #5
          Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

          On Thu, 01 May 2008 05:32:19 GMT, "biganthony via AccessMonster.c om"
          <u31673@uwewrot e:

          I said that my version of Sub sHook should replace the one in Dev's
          module. You probably replaced the entire module with my sub. Then the
          sDragDrop routine would not exist and you'd get the compile error you
          indicated.

          -Tom.

          >Hello Tom,
          >
          >I saw this thread, was interested in it and decided to try it out but I
          >receive the following error message when I compile the module: "Invalid Use
          >of AddressOfOperat or" on the line below:
          >
          >lpPrevWndPro c = apiSetWindowLon g(Hwnd, GWL_WNDPROC, AddressOf sDragDrop)
          >
          >I have copied the code from the Access Web site, substituted in your module,
          >created the form and placed the listbox on it.
          >
          >I am using Access 2003 SP2.
          >
          >Regards
          >Anthony
          >
          >
          >
          >Tom van Stiphout wrote:
          >>A2000 and above have the AddressOf operator.
          >>Follow Dev's example to the letter. Then replace the sHook function
          >>with this code:
          >>Sub sHook(Hwnd As Long, _
          > strFunction As String)
          > 'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
          >>AddrOf(strFun ction))
          > Select Case strFunction
          > Case "sDragDrop"
          > lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
          >>AddressOf sDragDrop)
          > Case Else
          > Debug.Assert False 'Need to setup this function as
          >>another Case.
          > End Select
          >>End Sub
          >>
          >>Works for me in A2007.
          >>Happy dropping,
          >>
          >>-Tom.
          >>
          >>>I am looking for VBA code that will work with Access 2003 to enable
          >>>dragging and dropping a file/folder name from Windows XP Explorer into
          >>[quoted text clipped - 29 lines]
          >>>
          >>>Thanks !

          Comment

          • John

            #6
            Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

            Tom,

            Your code was similar to what I tried unsuccessfully already, except
            that you added the Debug.Assert part. I copied and pasted your code
            for the "sHook" function, and Access 2003 still crashes when I try to
            open the form. Everything compiles fine.

            I even created a new, blank database (Access 2000 format), with the
            only form being "frmDragDro p". The only module in this database is
            Dev's module. Access 2003 still crashes to the desktop when I try to
            open the form.

            I stepped through the code using breakpoints, and all the code
            executes without any errors. However, between when the VBA code
            completes (after hitting F8 after the final End Sub) and the form is
            supposed to open, Access crashes.

            Any ideas or help you could provide would be appreciated. I am using
            Dev's code, with the exception of substituting your function, and I
            have double-checked everything, so I'm at a loss.

            Thanks,
            John


            On Wed, 30 Apr 2008 21:40:18 -0700, Tom van Stiphout
            <no.spam.tom774 4@cox.netwrote:
            >On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@ya hoo.com>
            >wrote:
            >
            >A2000 and above have the AddressOf operator.
            >Follow Dev's example to the letter. Then replace the sHook function
            >with this code:
            >Sub sHook(Hwnd As Long, _
            strFunction As String)
            'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
            >AddrOf(strFunc tion))
            Select Case strFunction
            Case "sDragDrop"
            lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
            >AddressOf sDragDrop)
            Case Else
            Debug.Assert False 'Need to setup this function as
            >another Case.
            End Select
            >End Sub
            >
            >Works for me in A2007.
            >Happy dropping,
            >
            >-Tom.
            >
            >
            >
            >>I am looking for VBA code that will work with Access 2003 to enable
            >>dragging and dropping a file/folder name from Windows XP Explorer into
            >>an Access form's text box. This is a common functionality that most
            >>Windows programs have, so I'm suprised it's not easier to implement in
            >>Access/VBA.
            >>
            >>Through Google, I found two VB6 examples and one VBA example on the
            >>Access Web written by Dev Ashish. The VB6 examples used loops to keep
            >>checking for the drag-drop Windows event and prevented my form from
            >>loading. Dev's code looked much better, but it didn't work in Accesss
            >>2003. It looks like it was written prior to Access 2000. The link to
            >>Dev's code is here:
            >>http://www.mvps.org/access/api/api0032.htm
            >>I successfully use many other API calls in my project, but trying to
            >>debug Dev's code is way over my head.
            >>
            >>Dev's code refers to a class module named "AddrOf" that is available
            >>here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
            >>However, this module has errors under Access 2003 when it runs, one of
            >>which says a DLL file is missing.
            >>
            >>VBA under Access 2003 has a built-in function, "AddressOf" , that
            >>should accomplish the same thing as the older "AddrOf" class module,
            >>but I can't seem to get it to work. When I try using the "AddressOf"
            >>function in Dev's code, it compiles fine, but when it runs, Access
            >>2003 crashes back to the desktop.
            >>
            >>If anyone has VBA code that will allow dragging and dropping
            >>file/folder names from Windows explorer into a form's textbox/listbox,
            >>would you please be kind enough to provide me with the code, or a link
            >>to the code.
            >>
            >>Thanks !

            Comment

            • John

              #7
              Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

              Tom,

              I did get it working finally. After starting from scratch again, and
              copying and pasting Dev's code, I realized I had changed "sDragDrop"
              from a Sub to a Function because I thought "AddressOf" would only work
              with a function.

              I had also added an "Option Explicit" to the top of Dev's module. The
              "Option Explicit" seems to cause problems with the form. I can drag
              and drop a file name from Windows Explorer, but if the "Option
              Explicit" is present, the form will lock up afterwards. I don't
              understand this, but it seems to work now.

              I tried testing the "frmDragDro p" many more times to make sure it was
              now stable, and occasionally the form seems to lock up, even with the
              "Option Explicit" commented out. Maybe this was because I didn't
              reboot my machine between my original errors and fixing the problem.
              Can you think of any reason why the form would lock up like this, but
              only occasionally?

              I will probably add this feature to my program, but I will give the
              user's the option to disable it (I will probably have it disabled by
              default).

              Also, I don't fully understand why you have the Debug.Assert also.
              Could you explain this. I know the Debug.Assert stops the code from
              running at that point, but I have never used it.

              Thanks for the help,
              John


              On Wed, 30 Apr 2008 21:40:18 -0700, Tom van Stiphout
              <no.spam.tom774 4@cox.netwrote:
              >On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@ya hoo.com>
              >wrote:
              >
              >A2000 and above have the AddressOf operator.
              >Follow Dev's example to the letter. Then replace the sHook function
              >with this code:
              >Sub sHook(Hwnd As Long, _
              strFunction As String)
              'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
              >AddrOf(strFunc tion))
              Select Case strFunction
              Case "sDragDrop"
              lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
              >AddressOf sDragDrop)
              Case Else
              Debug.Assert False 'Need to setup this function as
              >another Case.
              End Select
              >End Sub
              >
              >Works for me in A2007.
              >Happy dropping,
              >
              >-Tom.
              >
              >
              >
              >>I am looking for VBA code that will work with Access 2003 to enable
              >>dragging and dropping a file/folder name from Windows XP Explorer into
              >>an Access form's text box. This is a common functionality that most
              >>Windows programs have, so I'm suprised it's not easier to implement in
              >>Access/VBA.
              >>
              >>Through Google, I found two VB6 examples and one VBA example on the
              >>Access Web written by Dev Ashish. The VB6 examples used loops to keep
              >>checking for the drag-drop Windows event and prevented my form from
              >>loading. Dev's code looked much better, but it didn't work in Accesss
              >>2003. It looks like it was written prior to Access 2000. The link to
              >>Dev's code is here:
              >>http://www.mvps.org/access/api/api0032.htm
              >>I successfully use many other API calls in my project, but trying to
              >>debug Dev's code is way over my head.
              >>
              >>Dev's code refers to a class module named "AddrOf" that is available
              >>here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
              >>However, this module has errors under Access 2003 when it runs, one of
              >>which says a DLL file is missing.
              >>
              >>VBA under Access 2003 has a built-in function, "AddressOf" , that
              >>should accomplish the same thing as the older "AddrOf" class module,
              >>but I can't seem to get it to work. When I try using the "AddressOf"
              >>function in Dev's code, it compiles fine, but when it runs, Access
              >>2003 crashes back to the desktop.
              >>
              >>If anyone has VBA code that will allow dragging and dropping
              >>file/folder names from Windows explorer into a form's textbox/listbox,
              >>would you please be kind enough to provide me with the code, or a link
              >>to the code.
              >>
              >>Thanks !

              Comment

              • biganthony via AccessMonster.com

                #8
                Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                Tom,

                I followed your instaructions - I am using Dev''s code with the exception of
                the sHook sub. I copied and pasted your sHook sub into the code, replacing
                Dev's.

                The sDragDrop does exit in my module.

                Anthony


                Tom van Stiphout wrote:
                >I said that my version of Sub sHook should replace the one in Dev's
                >module. You probably replaced the entire module with my sub. Then the
                >sDragDrop routine would not exist and you'd get the compile error you
                >indicated.
                >
                >-Tom.
                >
                >>Hello Tom,
                >>
                >[quoted text clipped - 39 lines]
                >>>>
                >>>>Thanks !
                --
                Message posted via AccessMonster.c om


                Comment

                • biganthony via AccessMonster.com

                  #9
                  Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                  I should have said, "The sDragDrop does exist in my module."


                  biganthony wrote:
                  >Tom,
                  >
                  >I followed your instaructions - I am using Dev''s code with the exception of
                  >the sHook sub. I copied and pasted your sHook sub into the code, replacing
                  >Dev's.
                  >
                  >The sDragDrop does exit in my module.
                  >
                  >Anthony
                  >
                  >>I said that my version of Sub sHook should replace the one in Dev's
                  >>module. You probably replaced the entire module with my sub. Then the
                  >[quoted text clipped - 8 lines]
                  >>>>>
                  >>>>>Thanks !
                  --
                  Message posted via http://www.accessmonster.com

                  Comment

                  • Tom van Stiphout

                    #10
                    Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                    On Thu, 01 May 2008 21:54:01 GMT, "biganthony via AccessMonster.c om"
                    <u31673@uwewrot e:

                    Send me an email (my spam trap should be easy to figure out) and I
                    will send you my version. Perhaps there is something else I
                    overlooked.

                    -Tom.


                    >I should have said, "The sDragDrop does exist in my module."
                    >
                    >
                    >biganthony wrote:
                    >>Tom,
                    >>
                    >>I followed your instaructions - I am using Dev''s code with the exception of
                    >>the sHook sub. I copied and pasted your sHook sub into the code, replacing
                    >>Dev's.
                    >>
                    >>The sDragDrop does exit in my module.
                    >>
                    >>Anthony
                    >>
                    >>>I said that my version of Sub sHook should replace the one in Dev's
                    >>>module. You probably replaced the entire module with my sub. Then the
                    >>[quoted text clipped - 8 lines]
                    >>>>>>
                    >>>>>>Thanks !

                    Comment

                    • Tom van Stiphout

                      #11
                      Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                      On Thu, 01 May 2008 14:28:44 -0700, John <azgtrplayer@ya hoo.com>
                      wrote:

                      Good work.
                      I would be REALLY surprised if Option Explicit causes the problems you
                      describe. It is essentially no more than a flag to the compiler to say
                      "don't accept undeclared variables".

                      Does your code compile? (debug compile)

                      On the topic of Debug.Assert: that's a habit of mine which I call
                      Defensive Programming.
                      Note that the sHook procedure is designed to only work when we pass in
                      "sDragDrop" . So what if an innocent maintenance programmer, or even
                      myself a year later when I have forgotten all about this function,
                      would call it with a different strFunction argument. It could even be
                      a typo. Wouldn't it be nice if the first time the developer unit tests
                      the new code it would stop and tell him/her that an unexpected value
                      was passed in? I think a MsgBox is not as appropriate because this
                      kind of error should really not happen in Production, only during
                      development.
                      So any time I write a Select Case statement with an enumerated list of
                      options I am planning on handling, I write the Case Else to say "Yo!
                      You didn't implement this option". That's what Debug.Assert does for
                      me. In Production, it compiles to nothing and thus does not slow down
                      the program.
                      It would have been better if I had written:
                      Debug.Assert False 'Option not implemented.

                      -Tom.

                      >Tom,
                      >
                      >I did get it working finally. After starting from scratch again, and
                      >copying and pasting Dev's code, I realized I had changed "sDragDrop"
                      >from a Sub to a Function because I thought "AddressOf" would only work
                      >with a function.
                      >
                      >I had also added an "Option Explicit" to the top of Dev's module. The
                      >"Option Explicit" seems to cause problems with the form. I can drag
                      >and drop a file name from Windows Explorer, but if the "Option
                      >Explicit" is present, the form will lock up afterwards. I don't
                      >understand this, but it seems to work now.
                      >
                      >I tried testing the "frmDragDro p" many more times to make sure it was
                      >now stable, and occasionally the form seems to lock up, even with the
                      >"Option Explicit" commented out. Maybe this was because I didn't
                      >reboot my machine between my original errors and fixing the problem.
                      >Can you think of any reason why the form would lock up like this, but
                      >only occasionally?
                      >
                      >I will probably add this feature to my program, but I will give the
                      >user's the option to disable it (I will probably have it disabled by
                      >default).
                      >
                      >Also, I don't fully understand why you have the Debug.Assert also.
                      >Could you explain this. I know the Debug.Assert stops the code from
                      >running at that point, but I have never used it.
                      >
                      >Thanks for the help,
                      >John
                      >
                      >
                      >On Wed, 30 Apr 2008 21:40:18 -0700, Tom van Stiphout
                      ><no.spam.tom77 44@cox.netwrote :
                      >
                      >>On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@ya hoo.com>
                      >>wrote:
                      >>
                      >>A2000 and above have the AddressOf operator.
                      >>Follow Dev's example to the letter. Then replace the sHook function
                      >>with this code:
                      >>Sub sHook(Hwnd As Long, _
                      > strFunction As String)
                      > 'lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
                      >>AddrOf(strFun ction))
                      > Select Case strFunction
                      > Case "sDragDrop"
                      > lpPrevWndProc = apiSetWindowLon g(Hwnd, GWL_WNDPROC,
                      >>AddressOf sDragDrop)
                      > Case Else
                      > Debug.Assert False 'Need to setup this function as
                      >>another Case.
                      > End Select
                      >>End Sub
                      >>
                      >>Works for me in A2007.
                      >>Happy dropping,
                      >>
                      >>-Tom.
                      >>
                      >>
                      >>
                      >>>I am looking for VBA code that will work with Access 2003 to enable
                      >>>dragging and dropping a file/folder name from Windows XP Explorer into
                      >>>an Access form's text box. This is a common functionality that most
                      >>>Windows programs have, so I'm suprised it's not easier to implement in
                      >>>Access/VBA.
                      >>>
                      >>>Through Google, I found two VB6 examples and one VBA example on the
                      >>>Access Web written by Dev Ashish. The VB6 examples used loops to keep
                      >>>checking for the drag-drop Windows event and prevented my form from
                      >>>loading. Dev's code looked much better, but it didn't work in Accesss
                      >>>2003. It looks like it was written prior to Access 2000. The link to
                      >>>Dev's code is here:
                      >>>http://www.mvps.org/access/api/api0032.htm
                      >>>I successfully use many other API calls in my project, but trying to
                      >>>debug Dev's code is way over my head.
                      >>>
                      >>>Dev's code refers to a class module named "AddrOf" that is available
                      >>>here: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19
                      >>>However, this module has errors under Access 2003 when it runs, one of
                      >>>which says a DLL file is missing.
                      >>>
                      >>>VBA under Access 2003 has a built-in function, "AddressOf" , that
                      >>>should accomplish the same thing as the older "AddrOf" class module,
                      >>>but I can't seem to get it to work. When I try using the "AddressOf"
                      >>>function in Dev's code, it compiles fine, but when it runs, Access
                      >>>2003 crashes back to the desktop.
                      >>>
                      >>>If anyone has VBA code that will allow dragging and dropping
                      >>>file/folder names from Windows explorer into a form's textbox/listbox,
                      >>>would you please be kind enough to provide me with the code, or a link
                      >>>to the code.
                      >>>
                      >>>Thanks !

                      Comment

                      • biganthony via AccessMonster.com

                        #12
                        Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                        Thanks for the code Tom. It works.

                        Anthony



                        Tom van Stiphout wrote:
                        >Send me an email (my spam trap should be easy to figure out) and I
                        >will send you my version. Perhaps there is something else I
                        >overlooked.
                        >
                        >-Tom.
                        >
                        >>I should have said, "The sDragDrop does exist in my module."
                        >>
                        >[quoted text clipped - 13 lines]
                        >>>>>>>
                        >>>>>>>Thanks !
                        --
                        Message posted via AccessMonster.c om


                        Comment

                        • Tom van Stiphout

                          #13
                          Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                          On Sun, 04 May 2008 21:50:21 GMT, "biganthony via AccessMonster.c om"
                          <u31673@uwewrot e:

                          Super. What was different between yours and mine?
                          -Tom.


                          >Thanks for the code Tom. It works.
                          >
                          >Anthony
                          >
                          >
                          >
                          >Tom van Stiphout wrote:
                          >>Send me an email (my spam trap should be easy to figure out) and I
                          >>will send you my version. Perhaps there is something else I
                          >>overlooked.
                          >>
                          >>-Tom.
                          >>
                          >>>I should have said, "The sDragDrop does exist in my module."
                          >>>
                          >>[quoted text clipped - 13 lines]
                          >>>>>>>>
                          >>>>>>>>Thank s !

                          Comment

                          • biganthony via AccessMonster.com

                            #14
                            Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox

                            Tom,
                            The code was exactly the same, which I don't understand why the error
                            occurred. I deleted my attempt when I received yours but I have the feeling
                            that I foolishly copied the code to the module behind the form, instead of a
                            new module. I can't believe I let that happen. I totally missed the line on
                            the Dev''s site where he says: "Paste this code in a new module." !!

                            Thanks for your help - without having your code to look at I doubt if I had
                            picked up my own mistake.
                            Anthony



                            Tom van Stiphout wrote:
                            >Super. What was different between yours and mine?
                            >-Tom.
                            >
                            >>Thanks for the code Tom. It works.
                            >>
                            >[quoted text clipped - 11 lines]
                            >>>>>>>>>
                            >>>>>>>>>Than ks !
                            --
                            Message posted via AccessMonster.c om


                            Comment

                            • Gord

                              #15
                              Re: Drag and Drop File Name from Windows Explorer into Access FormTextbox

                              If I'm reading the code correctly for 'Sub sDragDrop' it is limited to
                              a path length of 50 characters for each file. This seems to be
                              confirmed by testing, where if I drag and drop the files

                              C:\Documents and Settings\gdt\My Documents\a.txt
                              C:\Documents and Settings\gdt\My Documents\b.txt

                              the form says "2 files dropped" and lists them correctly, but if I
                              rename the files to

                              C:\Documents and Settings\gdt\My Documents\fooba r.txt
                              C:\Documents and Settings\gdt\My Documents\bazbi n.txt

                              and try again the form says "1 files dropped", the listbox displays

                              C:\Documents and Settings\gdt\My Documents\fooba r

                              (truncated after 49 characters) and A2007 gets somewhat grumpy after
                              that.

                              Comment

                              Working...