Reputation: 5097
How to put a File path control in VBA front panel? I want the user to be able to select the browse button and select the file path rather than putting up dialog boxes all over the place. I need the user to select three or more file paths.
Upvotes: 4
Views: 8082
Reputation: 1465
After re-re-reading your Q, it seams you want to steer away from dialog boxes!Oh well, I was going to say
I could post the hack about using MSDIAG on VBA, that explains how you can patch your registry to enable its use under VBA, without having other MS-VB products installed... but I rather have you google that one... you can certainly understand why.
But you don't want Dialog Boxes... you want controls and buttons: Use listboxes! To populate your listbox, use the Dir command (using method additem of the listbox). Two phases for achieving that:
Finally, under OnClick and OnDoubleClick of the listbox, you must interpret the listbox default property (Item), check for "->" and use ChDir to change directory and repopulate, or you'll have your file selected.
The write up is sooooooo much more complicated than the code... trust me.
Upvotes: 3
Reputation: 91376
Perhaps the browse for folder API from the Microsoft MVPs site would suit:
http://www.mvps.org/access/api/api0002.htm
It uses SHBrowseForFolder mentioned by fwzgekg, and does not return a file dialog, it returns a browsable list of folders.
Upvotes: 1
Reputation: 11148
There is not direct VBA function for that. You can decide to combine a form (Access form, or a generic microsoft form) with 2 controls: (1) text box (2) browse button (which will finally use the fileDialog command or a windows API).
Upvotes: 1
Reputation: 321
Do you mean VBA for Microsoft Office or just general VBA?
In Office, Application.FileDialog(msoFileDialogOpen)
.
Otherwise, look at the Win32 API function SHBrowseForFolder
(in shell32.dll). You can import it for use into VBA using the Declare Function
keywords.
Upvotes: 2