April 2006
Beginner
1114 pages
98h 16m
English
Application.GetSaveAsFilename([InitialFilename], [FileFilter], [FilterIndex], [Title], [ButtonText])
Displays the Save File As dialog box and returns a filename or False if no file is selected. Does not save the file.
|
Argument |
Setting |
|---|---|
|
|
The name to display in the File text box |
|
Other arguments |
The following code saves the active workbook as a web page, closes the newly saved file, and reopens the original workbook in XLS format:
Sub TestGetSaveAs( )
Dim fname1 As String, fname2 As String, fname3 As String
Dim fltr As String
' Save changes
ActiveWorkbook.Save
' Get current filename.
fname1 = ActiveWorkbook.Name
' Get filename for web page.
fname2 = Replace(fname1, "xls", "htm")
fltr = "Web page (*.htm),*.htm,XML data (*.xml),*.xml," & _
"XML Style Sheet (*.xsl),*.xsl"
' Show the Save As dialog.
fname3 = Application.GetSaveAsFilename(fname2, fltr, _
1, "Export to web")
' If not cancelled, save the file as a web page.
If fname3 <> "False" Then _
ActiveWorkbook.SaveAs fname3, xlHtml
' Reopen the original file.
Workbooks.Open fname1
' Close the web page file.
Workbooks(fname2).Close
End SubRead now
Unlock full access