Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- From: John <azgtrplayer@xxxxxxxxx>
- Date: Thu, 01 May 2008 14:28:44 -0700
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 "frmDragDrop" 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.tom7744@xxxxxxx> wrote:
On Wed, 30 Apr 2008 13:10:08 -0700, John <azgtrplayer@xxxxxxxxx>.
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 = apiSetWindowLong(Hwnd, GWL_WNDPROC,
AddrOf(strFunction))
Select Case strFunction
Case "sDragDrop"
lpPrevWndProc = apiSetWindowLong(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/codes.asp?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 !
- Follow-Ups:
- Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- From: Tom van Stiphout
- Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- References:
- Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- From: Tom van Stiphout
- Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- Prev by Date: Re: Access on VPN -- seeking solutions
- Next by Date: Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- Previous by thread: Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- Next by thread: Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- Index(es):
Relevant Pages
|
Loading