Getsaveasfilename is called through application, and application is used through the VBA environment, so this example gives you the example code that calls the Save As dialog box in Excel.
Its format is as follows:
Dim Filename as String
Filename = Application.getsaveasfilename (filefilter:= "file name, *. Format")
First, the code is as follows
Dim Filesavename
Filesavename = Application.getsaveasfilename (filefilter:= "Text Files (*.txt), *.txt")
If filesavename <> False Then
MsgBox "Save as" & Filesavename
End If
Second, the title of the specified dialog box
Dim fname as String
Workbooks.Open filename:=2099 results. xls
ActiveSheet.Range (A1). Value = Save
FName = Application.getsaveasfilename (_
Initialfilename:= score saved. xls, _
title:= here is the title text)
If fname <> False Then
ActiveWorkbook.SaveAs Filename:=fname
End If
Knowledge Development:
Application.getsaveasfilename method: Simple is to show the Save As dialog box, user-friendly input file name to save
Grammar:
Expression. Getsaveasfilename (InitialFileName, FileFilter, FilterIndex, Title, ButtonText)
expression Required. The expression returns the type object of the application
InitialFileName variant type, optional. Specifies the initial filename
FileFilter variant type, optional. A string that specifies the file filter criteria, such as: "Text file, *.txt"
FilterIndex Variant type, optional. Specifies the index number of the default file filter criteria, ranging from 1 to the number of filter criteria specified by FileFilter
Title Variant type, optional. Specify a dialog box title
ButtonText Variant type, optional. For Macintosh only
When using, please note the following:
1. If you omit the initialfilename parameter, Microsoft Excel takes the name of the active workbook as the initial file name
2. If the FileFilter parameter is omitted, the default parameter value is "All Files (*.*), *.*"
3. If you omit the FilterIndex parameter, or if the value is greater than the number of available filters, the first file filter condition is used
4. If you omit the title argument, the default caption is used.