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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a file or folder

Status
Not open for further replies.

Graffy

Technical User
Jan 17, 2008
8
US
Hi, how do I show one dialog that will allow a person to select either a file or a folder from any drive on their computer?
 
Just to clarify: I don't want a dialog that only allows the user to select a file. I don't want a dialog that only allows the user to select a folder. I want a dialog that allows the user to select either a file or a folder.
 
Application.FileDialog(msoFileDialogOpen)

just make a google search, you will got a lot of good information.
 
The FileDialog object can be used to select either files or folders, but not both at the same time.

What I want is a dialog that shows folders and files, and the user to have the choice to select either a folder or a file.
 
I tried doing the following, and it works for folders, but when I try to select a file, it returns a "file not found" error. Darn, I thought I had it with this.

Code:
Const BIF_editbox = &H10
Const BIF_browseincludefiles = &H4000

Private Sub Form_Load()
Dim objShell As Shell32.Shell
Dim objFolder As Shell32.Folder2
Set objShell = New Shell32.Shell

Set objFolder = objShell.BrowseForFolder(&H0, "Select the file", _
                BIF_editbox + BIF_browseincludefiles, "")
MsgBox objFolder.Self.Path & " " & _
       objFolder.Self.Name & " "

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top