Microsoft Office Tutorials and References
In Depth Information
16.1.6.3 FileDialog property
16.1.6.3 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:
msoFileDialogFilePicker
msoFileDialogFolderPicker
msoFileDialogOpen
msoFileDialogSaveAs
To illustrate, the following code:
' Open dialog
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
' Display path
MsgBox .SelectedItems(1)
End With
allows the user to select a folder and then displays the folder's complete path.
16.1.6.4 FindFile method
This method, whose syntax is:
Application.FindFile
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 .
16.1.6.5 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