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 "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 !
.



Relevant Pages

  • Re: Will Old XP Applications Run on Windows7?
    ... nothing but crashes if you rush it a bit. ... Programs can crash due to hardware issues to. ... There are versions for Windows and Linux. ...
    (microsoft.public.windowsxp.general)
  • Re: Will Old XP Applications Run on Windows7?
    ... nothing but crashes if you rush it a bit. ... Programs can crash due to hardware issues to. ... There are versions for Windows and Linux. ...
    (microsoft.public.windowsxp.general)
  • Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
    ... I had also added an "Option Explicit" to the top of Dev's module. ... A2000 and above have the AddressOf operator. ... Sub sHook(Hwnd As Long, _ ... dragging and dropping a file/folder name from Windows XP Explorer into ...
    (comp.databases.ms-access)
  • Re: Word 2007 has stopped working on Vista Home Premium
    ... I probably earlier said it was worse when I tried to open a file first than using the shortcut icon on the desktop, but should have clarified that I normally use start/computer rather than than windows/e to open these files. ... I should also say that when I spoke of Word working in safe mode, I know that the tech and I opened 15 files once Word was open and that we opened Word from the icon and by first clicking on a file, but I don't think we did several runs at trying to open file by clicking on a file. ... I called them and was told the only driver available now is the one that comes with Vista. ... When I click the desktop icon, it is less than 50% crashes. ...
    (microsoft.public.word.application.errors)
  • Re: [opensuse] An old story, six years later (OT, or NOT?)
    ... The story was on an authentic, real life experience in the line of popular windows vs linux discussions of that time. ... The story was in favor of linux so much that quite a number of them decided to try and even completely convert to linux after reading it. ... frequent dolphin crashes, plasma multi activity setup crashes, desktop effects crashes, device notifier crashes, etc... ... With KDE4, so many new concepts and layers of complexity have been introduced. ...
    (SuSE)