PDA

View Full Version : Drag and Drop Files from Explorer



johnsonm
10-07-2005, 02:28 PM
I am creating a VBA userform that loads files into a listbox. What I want to do is give the user the ability to drag and drop files from windows explorer. Is this possible to do in VBA? Any help on this would be greatly appreciated.

Thanks
Murray Johnson
Edmonton Catholic Schools

fumei
10-11-2005, 03:15 AM
1. Please state what application and version you are doing this in.

2. If I understand correctly, what you are asking for is the ability to have a UserForm lose its focus so someone can give Windows Explorer the focus, select files in Explorer, drag them back to the UserForm, give focus back to the UserForm, extract the variable contents of what is being dragged (that is, the string names) and put those string names into the listbox.

Correct?

johnsonm
10-11-2005, 07:32 AM
1. It is in AutoCAD 2006

2. Yes, that is what I want to do.

Am I completely off base in thinking plain VBA can do this?

Tommy
10-12-2005, 06:21 AM
Hi johnsonm,

Welcome to VBAexpress!

To my knowledge VBA does not support Drag and Drop.

As an alternative :) how about using the OpenFileNmae found here http://msdn.microsoft.com/library/d...penfilename.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxstructures/openfilename.asp) with a discussion here http://www.vbaexpress.com/forum/showthread.php?t=3518. Fill the listbox using this maybe? :think: The only problem I see is having drawings/dxf/dwt's from different directories, but that can be fixed with the full path to the file (of course I am assuming that you want a list of drawings).

xld
10-12-2005, 09:15 AM
Stephen Bullen has a DragDrop.exe on his site at http://www.oaltd.co.uk/Excel/SBXLPage.asp. I haven't tried it personally, but you might want to check it out.

MOS MASTER
10-13-2005, 02:33 PM
Nice example Bob! :yes I always loved Steven's site...