I am looking for info on dragging files from Explorer to an Access
listbox or similar in Access 2000 (wanting to capture path and file
name to store in a table).
I am aware of the "Access Web" article on how to do something like
this in A97 and I attempted the same approach in 2000 without success
(including Getz and Kaplan's AddrOf module). I know Access 2000 has
it's own AddressOf operator but I have not been cleaver enough to
adapt the Access Web '97 code to make use of that.
I also know Felix Lima has described a method (I think for A2K, which
involves compiling a DLL especially for the purpose using VB (see:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=01t8T1vuBHA.2048%40cpmsftngxa07).
(Maybe I should buy VB and give this a go).
Clearly this is not an easy thing to do, but if anyone has a working
Access 2000 code example or have some hard-earned knowledge they wish
to share on the subject, I would be most grateful!
Kind regards
Stuart MacKinnon
Auckland, NZ
>I am looking for info on dragging files from Explorer to an Access
>listbox or similar in Access 2000 (wanting to capture path and file
>name to store in a table).
Why not just use a popup with its own listboxes which show directories
and files? Then the popup could return the full path. You'd use that
to search. I would prefer a treeview directory control using the fso.
But I can understand others preference for a non-ActiveX approach with
a couple of listboxes. In fact, you could just call the file open/save
dialog using the API. You click on the file, it can return the full
path, as well, I believe. But all three methods involve using a popup
window (or you could embed as a visible/invisible subform - whatever
your preference), but not opening Explorer and dragging the name into
an Access control.
Thanks Mark, I can see these options could work but I persisted with
trying to drag names from Explorer.
In the end, I found the only method that would work was to 'bite the
bullet' and compile a custom VB6 DLL using Felix Lima's method (see
for example: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=neCf8.8873%24Ek1.1063230%40news-nb00s0.nbnet.nb.ca).
His example allowed dropping to a text box only. I modified the DLL
to allow dropping to a list box with the following code (for the
benefit of any others who are interested).
In the CDragDrop Class Module, instead of:
~~~~~~~~~~~~~~~~~
Public Property Set textbox(txtin As Object)
Set txt = txtin
End Property
~~~~~~~~~~~~~~~~~
Use:
~~~~~~~~~~~~~~~~~
Public Property Set ListBox(lstin As Object)
Set lst = lstin
End Property
~~~~~~~~~~~~~~~~~
AND in the "Sub AcceptDroppedFiles" in the CDragDrop Class Module,
instead of:
~~~~~~~~~~~~~~~~~
txt.Text = txt.Text & Left$(sFilename, lReturn) & vbCrLf
~~~~~~~~~~~~~~~~~
Use:
~~~~~~~~~~~~~~~~~
lst.Rowsource = lst.Rowsource & Left$(sFilename, lReturn) & ";"
~~~~~~~~~~~~~~~~~
And the form containing the listbox should have the following code:
'***BEGIN CODE*****
Option Compare Database
Option Explicit
Dim CDrag As New CDragDrop
Private Sub Form_Load()
'Subclass the form
Set CDrag.ListBox = Me.List1
Set CDrag.Form = Me
CDrag.SubClassHookForm
End Sub
Private Sub Form_Unload(Cancel As Integer)
'UnSubclass the form
CDrag.SubClassUnHookForm
Set CDrag.Form = Nothing
Set CDrag.ListBox = Nothing
Set CDrag = Nothing
End Sub
'***END CODE*****
Enjoy. And my thanks to all the people who share their knowledge in
these groups!!!
Regards
Stuart MacKinnon
Auckland
New Zealand