Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
- From: John <azgtrplayer@xxxxxxxxx>
- Date: Thu, 01 May 2008 13:54:46 -0700
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 "frmDragDrop". 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.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 !
- 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: Export to CSV Truncates 2nd Memo Field
- Next by Date: Relationships vanish
- 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
|