Eric
Eric

Reputation: 51

Show files only (not folders) in a Office.FileDialog window?

I have a procedure using the Office.FileDialog object that goes to a remote folder, sets a FileDialog.Filter to search for a specific file in that folder (i.e., .Filter = "\\PATH\MYFILE*.pdf"), and then uses FileDialog.Show to display a window containing only that target file. When the window is displayed, it contains not only my target file but also all of the sub-folders in the target folder. How can I display only the files, and not the sub-folders?

Upvotes: 0

Views: 345

Answers (2)

Ricky
Ricky

Reputation: 98

This will show only .pdf Files in the FileDialog. Just Add the specific path to the folder you want to open the FileDialog to in the quotations after ChDir "YourFile_Path".

Dim myFile As String
ChDir "C:\Users\Documents"
myFile = Application.GetOpenFilename(Title:="Import pdf File", FileFilter:="Pdf Files *.pdf (*.pdf),")

Upvotes: 0

Roie R
Roie R

Reputation: 139

As filtering applies only to files, and there's nothing of the kind in fileDialogType - I don't think what you're asking for is possible in VBA.

Upvotes: 2

Related Questions