473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:
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 !
Jun 27 '08 #1
16 11841
On Wed, 30 Apr 2008 13:10:08 -0700, John <az*********@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 !
Jun 27 '08 #2
On Wed, 30 Apr 2008 21:40:18 -0700, Tom van Stiphout
<no************ *@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 <az*********@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 !
Jun 27 '08 #3
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
http://www.accessmonster.com/Uwe/For...ccess/200805/1

Jun 27 '08 #4
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 !
Jun 27 '08 #5
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************ *@cox.netwrote:
>On Wed, 30 Apr 2008 13:10:08 -0700, John <az*********@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 !
Jun 27 '08 #6
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************ *@cox.netwrote:
>On Wed, 30 Apr 2008 13:10:08 -0700, John <az*********@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 !
Jun 27 '08 #7
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
http://www.accessmonster.com/Uwe/For...ccess/200805/1

Jun 27 '08 #8
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

Jun 27 '08 #9
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 !
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2604
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
8
20840
by: WindAndWaves | last post by:
Hi everyone, Has anyone got any experience with drop and drag in Access? I would like to make a calendar style form where my users can drop and drag appointments.... I am using Access 2003 and I have access to .net and the like, but I would really like to keep it simple.
5
3228
by: IdeaMan | last post by:
Windows 2000 Access 97 I am working on an issue tracking DB, where I need to link (not attach due to size)screen prints of various system errors. I have created a public folder on a network drive to store these images, under the assumption that no one will originally save them to that location. To resolve this, I need to copy the file to this location without possibility of user error in selecting the correct folder (the DB is to be...
5
4967
by: Clyde | last post by:
I am trying to implement the user feedback provided by Windows Explorer when draggng a filename from one place to another. I have the drag and drop action worked out but have had no luck in finding how to capture the piece of the screen into a bitmap to simulate the movement. I know this could be done with the Windows API but can't find any way to do it with .Net functions. Any help is appreciated.
4
3067
by: Dave | last post by:
I need to add the ability to drag from a Windows Form and drop into a non dotNet application. For example, having a generated image in my app that I wish to drag out into explorer as a friendly way to save it. I have tried creating the object that I place into the DoDragDrop() by inheriting the COM interfaces IDropSource and IDataObject with no luck. If anyone can help I am very much open to suggestions. Thanks in advance!
0
2863
by: Yavuz Bogazci | last post by:
Hi, i have build a form with a listbox and the function that he user can drag and drop files from the windows explorer in this listbox. this works for me when i start it on my localmachine. But when i put my Apps .exe file on my WebServers WWWROOT directory and call it from the internet explorer. the application starts with the following error message.
5
10159
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files dropped onto it.. does anyone have any examples of this? thanks
1
2303
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the structure in TreeView2 (putting files in different folders and such...like you do when you create a structure for burning a CD). I have two questions. 1. How can I remember the full path from TreeView1 (when it comes time to actually do...
2
5280
by: Andreas Mueller | last post by:
Hi All, I'm trying to show a context menu during a drag drop operation similar to the windows explorers right click drag and drop behavior (A full working sample is at the end of the post): void treeView1_DragDrop(object sender, DragEventArgs e) { ContextMenu mnu = new ContextMenu(); mnu.MenuItems.Add("Click me", OnCmClick);
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.