Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hepl required in using Browseforfolder command 1

Status
Not open for further replies.

arunmd1

Programmer
Mar 20, 2008
24
FR
Hi friends,
I am a creating a tool in Excel using VBA. In that once the user click on "Load" button, the tool should allow the user to select the folder which contains the input files. By default the path of selection will be starting from Desktop.
Now if i specify the (starting) path from which the usr has to select a file, it is not allowing the usr to go to the levels above the starting path. Is there a way to avoid this ?

My snippet is :

Dim Openat as variant

Openat = "E:\ExcelViewer"
Set shellObj = CreateObject("Shell.Application")
Set fldr = shellObj.BrowseForFolder(0, "Select folder containing input files", Openat)
If fldr Is Nothing Then
Exit Sub
End If

Here i am not not able to select any folders above this startin path "E:\ExcelViewer". In some cases this can happen.

Suggest a solution?
 
Hi guys ,
I got the solution.Anyways thanks macropad.

With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
End With

fldr = Application.FileDialogmsoFileDialogFolderPicker).SelectedItems(1)

'Code to get the files available in the user selected folder
Set fs = CreateObject("Scripting.FileSystemObject")
Set fl1 = fs.Getfolder(fldr)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top