Microsoft Office Tutorials and References
In Depth Information GetSaveAsFilename method
It is also possible to use multiple wildcard file filters, as in:
Backup Files (*.xlk; *.bak), *.xlk; *.bak
(Note the semicolons.) If the FileFilter argument is omitted, the default is:
All Files (*.*),*.*
Note that FileFilter can consist of more than one filter specification, separated by commas, as
Debug.Print Application.GetOpenFilename( _
"Text Files (*.txt),*.txt, _
Backup Files (*.xlk; *.bak), *.xlk; *.bak")
In this case, the optional FilterIndex parameter specifies which of the filters appears in the
"Files of type" drop-down list box. For instance, the following will cause the second filter (backup
files) to appear in the "Files of type" drop-down list box:
Debug.Print Application.GetOpenFilename( _
"Text Files (*.txt),*.txt, _
Backup Files (*.xlk; *.bak), *.xlk; *.bak", 2)
The optional Title parameter specifies the title of the dialog box. If this argument is omitted, the
title is Open. The ButtonText parameter is ignored by Windows, but used on the Macintosh.
The optional MultiSelect property is set to True to allow multiple filenames to be selected
and False to allow only one filename to be selected. The default value is False . To select
multiple files from the Open dialog, the user must hold down the Ctrl or Shift key.
The method returns the selected filename or the name entered by the user. The returned name may
also include a path specification. If the MultiSelect parameter is True , the return value is an
array of the selected filenames (even if only one filename is selected). The method returns False
if the user cancels the dialog box.
When Multiselect is True , we can determine the number of files selected by the user by using
the UBound function to get the upper bound for the returned array, as in:
NumFiles = UBound(Application.GetOpenFilename(MultiSelect:=True))
Note finally that this method may change the current drive or folder. GetSaveAsFilename method
This method is similar to the GetOpenFilename method, but instead displays the Save As dialog
box and gets a filename from the user without saving any files. The syntax is:
Application.GetSaveAsFilename( InitialFilename , _
FileFilter , FilterIndex , Title , ButtonText )
The optional InitialFilename parameter specifies the filename that is placed in the "File
name" text box on the Save As dialog. If this argument is omitted, Excel uses the name of the
active workbook. The other parameters (and return values) are the same as for the
GetOpenFilename method. As with GetOpenFilename, this method may change the current drive
or folder.
Search JabSto ::

Custom Search