将文件名从Windows资源管理器拖放到Access窗体文本框中 [英] Drag and Drop File Name from Windows Explorer into Access Form Textbox

查看:98
本文介绍了将文件名从Windows资源管理器拖放到Access窗体文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可与Access 2003配合使用的VBA代码,以便将文件/文件夹名称从Windows XP资源管理器拖放到

一个Access窗体中的文字框。这是Windows程序中最常见的功能,所以我很惊讶它在

Access / VBA中实现起来并不容易。


通过Google,我在Dev Ashish编写的

Access Web上找到了两个VB6示例和一个VBA示例。 VB6示例使用循环来保持

检查拖放Windows事件并阻止我的表单从

加载。 Dev'的代码看起来好多了,但它在Accesss

2003中没有用。它看起来像是在Access 2000之前编写的。链接到

Dev'的代码在这里:
http:// www.mvps.org/access/api/api0032.htm

我在我的项目中成功使用了许多其他API调用,但是尝试使用

调试Dev'我的代码就在我头上。


开发代码指的是一个名为AddrOf的类模块。可用的

这里: http://www.trigeminal.com/lang/1033/...p?ItemID=19#19

但是,此模块在Access 2003下有错误运行,其中一个

表示缺少DLL文件。


Access 2003下的VBA有一个内置函数,AddressOf,即

应该完成与旧版AddrOf相同的事情。课程模块,

但我似乎无法让它工作。当我尝试在Dev的代码中使用AddressOf

函数时,它编译得很好,但是当它运行时,Access

2003崩溃回桌面。


如果有人有VBA代码允许从Windows资源管理器中拖放

文件/文件夹名称到表单'的文本框/列表框,

你能不能给我提供代码,或链接

代码。


谢谢!

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 !

推荐答案

2008年4月30日星期三13:10:08 -0700,John< az ********* @ yahoo.com> ;

写道:


A2000及以上版本有AddressOf操作符。

按照Dev'的例子写信。然后用以下代码替换sHook函数



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' '需要设置此功能为

另一个案例。

结束选择

结束子


适合我在A2007。

快乐下降,


-Tom。
On Wed, 30 Apr 2008 13:10:08 -0700, John <az*********@yahoo.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 = 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.

>我正在寻找可与Access 2003一起使用的VBA代码,以便将文件/文件夹名称从Windows XP资源管理器拖放到Access窗体的文本框中。这是大多数Windows程序的常用功能,所以我很惊讶它在
Access / VBA中实现起来并不容易。

通过Google,我在Dev Ashish编写的访问Web上找到了两个VB6示例和一个VBA示例。 VB6示例使用循环来检查拖放Windows事件并阻止我的表单加载。 Dev的代码看起来好多了,但它在Accesss
2003中没有用。看起来它是在Access 2000之前编写的。
Dev'代码的链接在这里:
http://www.mvps.org/access/api/api0032.htm
我在项目中成功使用了许多其他API调用,但是试图调试开发代码是我的头脑。

开发代码指的是一个名为AddrOf的类模块。可以使用
http ://www.trigeminal.com/lang/1033/...p?ItemID = 19#19
但是,此模块运行时Access 2003下有错误,其中一个
表示缺少DLL文件。

Access 2003下的VBA具有内置函数AddressOf,它应该完成与旧版AddrOf相同的功能。课程模块,
但我似乎无法让它发挥作用。当我尝试在Dev的代码中使用AddressOf
函数时,它编译得很好,但是当它运行时,Access
2003会崩溃回桌面。

如果有人有VBA代码允许将Windows资源管理器中的文件/文件夹名称拖放到表单的文本框/列表框中,那么请您给我提供代码,或者代码链接。

谢谢!
>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 !


2008年4月30日星期三21:40:18 -0700,Tom van Stiphout

< no *** **********@cox.net写道:


我应该说:按照Dev'的例子写信,除了

从trigeminal.com获取AddrOf代码。


-Tom。
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.

>周三,30 2008年4月13:10:08 -0700,John< az ********* @ yahoo.com>
写道:

A2000及以上版本有AddressOf运算符。
按照Dev'的例子写信。然后用以下代码替换sHook函数
: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''需要将此功能设置为
另一个案例。 />
结束选择
结束子

在A2007为我工作。
快乐的下降,

-Tom。
>On Wed, 30 Apr 2008 13:10:08 -0700, John <az*********@yahoo.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 = 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.

>>我正在寻找可与Access 2003配合使用的VBA代码,以便将文件/文件夹名称从Windows XP资源管理器拖放到
一个Access窗体的文本框。这是大多数Windows程序的常用功能,所以我很惊讶它在
Access / VBA中实现起来并不容易。

通过Google,我在Dev Ashish编写的访问Web上找到了两个VB6示例和一个VBA示例。 VB6示例使用循环来检查拖放Windows事件并阻止我的表单加载。 Dev的代码看起来好多了,但它在Accesss
2003中没有用。看起来它是在Access 2000之前编写的。
Dev'代码的链接在这里:
http://www.mvps.org/access/api/api0032.htm
我在项目中成功使用了许多其他API调用,但是试图调试开发代码是我的头脑。

开发代码指的是一个名为AddrOf的类模块。可以使用
http ://www.trigeminal.com/lang/1033/...p?ItemID = 19#19
但是,此模块运行时Access 2003下有错误,其中一个
表示缺少DLL文件。

Access 2003下的VBA具有内置函数AddressOf,它应该完成与旧版AddrOf相同的功能。课程模块,
但我似乎无法让它发挥作用。当我尝试在Dev的代码中使用AddressOf
函数时,它编译得很好,但是当它运行时,Access
2003会崩溃回桌面。

如果有人有VBA代码允许将Windows资源管理器中的文件/文件夹名称拖放到表单的文本框/列表框中,那么请您给我提供代码,或者代码链接。

谢谢!
>>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 !


Hello Tom,


我看到这个帖子,对此感兴趣并决定尝试一下但是我在编译模块时收到以下错误消息:无效使用

of AddressOfOperator在下面的行:


lpPrevWndProc = apiSetWindowLong(Hwnd,GWL_WNDPROC,AddressOf sDragDrop)


我从Access网站复制了代码在你的模块中替换,

创建了表单并将列表框放在其上。


我正在使用Access 2003 SP2。


问候

Anthony


Tom van Stiphout写道:
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 AddressOfOperator" on the line below:

lpPrevWndProc = apiSetWindowLong(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及以上版本有AddressOf操作符。
按照Dev'的例子写信。然后用以下代码替换sHook函数
: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''需要将此功能设置为
另一个案例。 />
结束选择
结束子

在A2007为我工作。
快乐的下降,

-Tom。
>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.

>>我正在寻找可与Access 2003配合使用的VBA代码,以便将文件/文件夹名称从Windows XP资源管理器拖放到
>>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


[引用文字剪辑 - 29行]

[quoted text clipped - 29 lines]


>>
谢谢!
>>
Thanks !



-

通过AccessMonster.com发布消息
http://www.accessmonster.com/Uwe/For...ccess/ 200805/1

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200805/1


这篇关于将文件名从Windows资源管理器拖放到Access窗体文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆