My goal is to have the Save-as dialog box open at the end of the macro and to offer the xlsx format only, so that the VBA code will be dropped when the file is closed.
I worked on this task in a copy of my original macro file and it works (see code below). It even fills the file name window with the current file name.
When I pasted this same code into the original file, why would the file name window be empty? Everything else works. Is there another way to force the file name into the window? Is my original file corrupted? Could Windows 10 be a factor? Development of the original file started off in Win7. I'm a journeyman when it comes to VBA and this is new territory for me.
Thank you in advance for any insights or code improvements.
I worked on this task in a copy of my original macro file and it works (see code below). It even fills the file name window with the current file name.
When I pasted this same code into the original file, why would the file name window be empty? Everything else works. Is there another way to force the file name into the window? Is my original file corrupted? Could Windows 10 be a factor? Development of the original file started off in Win7. I'm a journeyman when it comes to VBA and this is new territory for me.
VBA Code:
Sub SaveAs()
Dim FileName As Variant
Dim txtMacroFile, txtFileName As String
txtMacroFile = ActiveWorkbook.Name
txtFileName = Replace(txtMacroFile, ".xlsm", "")
Application.DisplayAlerts = False
FileName = Application.GetSaveAsFilename(txtFileName, filefilter:="Excel Files (*.xlsx), *.xlsx")
If FileName = "False" Then Exit Sub
ActiveWorkbook.SaveAs FileName:=FileName, FileFormat:=51
Application.DisplayAlerts = True
End Sub
Thank you in advance for any insights or code improvements.
Last edited by a moderator: