SaveAs File Dialog Box
by Linda Quinn
Close Window
Print Page
This code allows the user to select the name of the file being saved.
It also allows the user to select the path where the file will be saved.
Dim filex As Variant
filex = Application. GetSaveAsFileName
( FileFilter: ="microsoft excel files (*.xls), *.xls", _
if filex <> false then
MsgBox "File Saved as " filex
End If
Application.GetSaveAsFileName will display a SaveAs dialog box
FILEX will contain the name of the saved file.
FILEX will be false if the dialog box is Cancelled.
FileFilter selects a default extension. This can be overridden in the dialog box.
Examples of Filter Statements
FileFilter:="Microsoft Excel Files (*.xls), *.xls"
FileFilter:="Text Files (*.txt), *.txt"
FileFilter:="Add-In Files(*.xla), *.xla"
FileFilter:="Text Files (*.txt), *.txt, Add-In Files(*.xla), *.xla"
The above will list both filters in the drop-down box
FileFilter:="Visual Basic Files(*.bas; *.txt), *.bas; *.txt"
Semi-colons separate multiple file types for a single filter type
Copyright © 2006-2019, LQSystems,Inc. All rights reserved.