VBA Code for File Browse
VBA Code for File Browse
(OP)
I am trying to find the vba code which will do the following:
1) bring up a file menu to browse for a folder
2) allow the user to use the mouse to choose a directory path
3) read this path into vba to establish a path for all file operations.
Does anyone know the vba code to do this?
Thanks
1) bring up a file menu to browse for a folder
2) allow the user to use the mouse to choose a directory path
3) read this path into vba to establish a path for all file operations.
Does anyone know the vba code to do this?
Thanks






RE: VBA Code for File Browse
RE: VBA Code for File Browse
Microsoft's license for VBA does not include access to certain objects, including the "Common Dialog" object used for opening and saving files, selecting colors, and printing. The workaround uses access to Windows API to get what you need (all perfectly legal).
I use this in my "Copy Custom Info" macro, as well. <http://www.esoxrepublic.com/freeware/>
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: VBA Code for File Browse
Do you know a way I could get the BrowseForFolder to reside in a Userform, just like a Listbox or something? Currently I have to click a Browse button to pop the BrowseForFolder Open, and then once it Closes...all I see is the selected path and my Browse button. I'd much rather just leave the BrowseForFolder open and available to the User.
Thanks,
Ken
RE: VBA Code for File Browse
If you want that kind of functionality in a user form that stays open you may have to create your own using standard file/folder access calls in VBA. If that's really something you want to do, here's a link to some sample code that'll get you well on your way.
http://www.blueclaw-db.com/listbox-directory.htm
Enjoy!
RE: VBA Code for File Browse
The link you provided solved my problem
Thanks
RE: VBA Code for File Browse
Thanks for the link. I am actually looking for a TreeView style interface that is avilable with full-blown VB-6. I was just hoping to keep the current project a SolidWorks macro, but VB-6 looks like my only alternative.
Thanks,
Ken
RE: VBA Code for File Browse
RE: VBA Code for File Browse
Why not display the selected path in a label? Then put a command button with "..." after the label. Clicking the command button launches the browse window and allows you to update the label text. Your code then takes the file path from the label caption.
RE: VBA Code for File Browse
Thanks! That is awesome, I have been looking for that for weeks.
That is what I'm currently doing, but I get complaints about having to hit the extra button all the time just to select the next higher or lower directory.
Ken
RE: VBA Code for File Browse
<http://allapi.net/>
http://www.EsoxRepublic.com-SolidWorks API VB programming help