Hi,
I have some VBA code. Somewhere in my application I want the user to be able to browse through the folders and files. My problem is how can I fetch the path of a folder while a user selects it? I do not want user to go to the file location. I just want the folder location.
Regards,
Gajendra Gupta
Hi Gupta, although this code looks like it will open the file it actually just gets you the file path and location:
Regards,Sub findfiles() Dim CurrentDir As Variant CurrentDir = CurDir() Dim fNameAndPath As Variant If fNameAndPath <> False Then Reset fNameAndPath = "" fNameAndPath = Application.GetOpenFilename(Filefilter:="Excel Files(*.xls), *.xls", Title:="Highlight File To Be Opened") If fNameAndPath = False Then MsgBox (" No File Selected! ") Else MsgBox "Selected file is:" & fNameAndPath End If Reset: End Sub
Simon
Simon thank for your reply. Yes this is the way you open a file but I do not want user to get in to the folder I just want him to select the folder and by selecting the folder only I should be able to get the folder path. Any idea?
Regards,
Gajendra Gupta
Hello Gajendra.Gupta,
Visit Chip Pearson's site. Here is a link that will take you to code examples of browsing for folders.
http://www.cpearson.com/excel/BrowseFolder.htm
Sincerely,
Leith Ross
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks