Microsoft Office Tutorials and References
In Depth Information
The Excel GetSaveAsFilename Method
FileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title, _
MultiSelect:=True)
‘ Exit if dialog box canceled
If Not IsArray(FileName) Then
MsgBox “No file was selected.”
Exit Sub
End If
‘ Display full path and name of the files
For i = LBound(FileName) To UBound(FileName)
Msg = Msg & FileName(i) & vbCrLf
Next i
MsgBox “You selected:” & vbCrLf & Msg
End Sub
The FileName variable is defined as a variant (not a string, as in the previous examples). I use
variant because FileName can potentially hold an array rather than a single filename.
The two examples in this section are available on the companion CD-ROM. The filename
is prompt for file.xlsm .
The Excel GetSaveAsFilename Method
The GetSaveAsFilename method is very similar to the GetOpenFilename method. It
displays a Save As dialog box and lets the user select (or specify) a file. It returns a filename and
path but doesn’t take any action. Like the GetOpenFilename method, all of the
GetSaveAsFilename method’s arguments are optional.
The syntax for this method is
Application.GetSaveAsFilename(InitialFilename, FileFilter, FilterIndex,
Title, ButtonText)
The arguments are
h InitialFilename : Optional. Specifies the suggested filename.
h FileFilter : Optional. A string specifying file-filtering criteria.
h FilterIndex : Optional. The index number of the default file-filtering criteria.
h Title : Optional. The title of the dialog box.
h ButtonText : For Macintosh only.
 
Search JabSto ::




Custom Search