Microsoft Office Tutorials and References
In Depth Information FileDialog property FileDialog property
This property programmatically opens a file-related dialog box and returns a FileDialog object. It
takes as parameter one of the following constants to indicate the type of dialog:
To illustrate, the following code:
' Open dialog
With Application.FileDialog(msoFileDialogFolderPicker)
' Display path
MsgBox .SelectedItems(1)
End With
allows the user to select a folder and then displays the folder's complete path. FindFile method
This method, whose syntax is:
displays the Open dialog box. If a file is opened successfully by the user, the method returns True .
If the user cancels the dialog box, the method returns False . GetOpenFilename method
This method displays the Open dialog box and gets a filename or filenames from the user but does
not open the files. Its syntax is:
Application.GetOpenFilename( FileFilter , _
FilterIndex , Title , ButtonText , MultiSelect )
The optional FileFilter parameter is a string that specifies what to put in the "Files of type"
drop-down list box in the Open dialog. In other words, it specifies file filtering criteria. This string
is in two parts, of the form:
description, filefilter
The first part is the description of the file type, and the second part is the MS-DOS wildcard
filefilter specification. The two parts are separated by a comma. Note that the first part is the string
that appears in the "Files of type" drop-down box in the Open dialog box. Thus, the first part also
includes the wildcard file-filter specification. Perhaps a few examples will help clarify:
Text files
Text Files (*.txt),*.txt
Lotus files
Lotus 1-2-3 (*.wk?), *.wk?
Add-In files
Add-In Files (*.xla),*.xla
Search JabSto ::

Custom Search