将文件拖入Access,如何查看文件详情? [英] Drag file into Access, how to check the file details?
问题描述
我喜欢将文件从 Windows 资源管理器或 Outlook 邮件中的附件拖到 MS-Access 中.
I like to drag a file from Windows Explorer or an attachment from an Outlook mail into MS-Access.
我发现我已经可以使用 Access BoundObjectFrame (https://msdn.microsoft.com/en-us/library/office/ff835725.aspx)作为从 Windows 资源管理器拖放文件的目标.
I discovered already I can use the Access BoundObjectFrame (https://msdn.microsoft.com/en-us/library/office/ff835725.aspx) as a target to drag and drop files from the Windows Explorer.
通过以下代码,我看到某些内容被放入该字段:
And with the following code I see that something was dropped into the field:
Private Sub OLE1_GotFocus()
Debug.Print "OLE1_GotFocus()"
Debug.Print " OLE1.Value: " & OLE1.Value
End Sub
但该值只是一些二进制信息.我想知道被删除的文件名,或者我想读取被删除文件中的内容(即一个文本文件被删除).
But the value is just some binary information. I want to know the file name which was dropped or I want to read what is in the dropped file (i.e. a text file is dropped).
我查看了所有属性并在互联网上进行了搜索,但没有找到解决方案.在我想做的事情之前,我猜想很多人都尝试过.
I looked at all the properties and searched on the internet but I did not find a solution. I would have guessed many people tried before what I want to do.
有什么想法吗?
推荐答案
我不认为 BoundObjectFrame 会得到你想要的.
I don't think the BoundObjectFrame will get you what you want.
我建议使用 ListView控件 改为 ActiveX 控件.它具有内置的拖放支持.
I suggest using a ListView Control instead, an ActiveX control. It has inbuilt Drag&Drop support.
演示:
在表单上,插入 Microsoft ListView 控件,版本 6.0
ActiveX 控件.
将其命名为 lvwDD
.
右键单击,ListViewCtrl-object,属性:将 OLEDropMode 设置为 1 - ccOLEDropManual
.
On a form, insert a Microsoft ListView Control, version 6.0
ActiveX control.
Name it lvwDD
.
In right-click, ListViewCtrl-object, Properties: set OLEDropMode to 1 - ccOLEDropManual
.
插入此事件过程:
Private Sub lvwDD_OLEDragDrop(Data As Object, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long
' https://msdn.microsoft.com/en-us/library/aa244109(v=vs.60).aspx
Const vbCFFiles = 15
If Data.GetFormat(vbCFFiles) Then
' https://msdn.microsoft.com/en-us/library/aa267471(v=vs.60).aspx
For i = 1 To Data.Files.Count
Debug.Print Data.Files(i)
Next i
Else
Debug.Print "No file(s) dropped."
End If
End Sub
在控件上拖放一个或多个文件,并在立即窗口 (Ctrl+G) 中查看输出.
Drag&Drop one or multiple files on the control, and see the output in the Immediate window (Ctrl+G).
这篇关于将文件拖入Access,如何查看文件详情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!