I would avoid naming a sub SaveAs, since there is a method by that name.
GetSaveAsFileName returns a path (a string), but doesn't actualy save the file.
You could either:
Add a bit that saves the workbook
Sub mySaveAs()
Dim TName As String
Dim SvAs As String
TName = Range("N5").Value
SvAs = Application.GetSaveAsFilename(InitialFileName:="Test Sheet for " & TName, FileFilter:="Excel Workbook (*.xls), *.xls", Title:="Save Workbook with Name")
If SvAs <> "False" Then
ThisWorkbook.SaveAs Filename:=SvAs
Else
MsgBox "Cancel pressed"
End If
or you could use the built in dialog
Sub trial()
Dim TName As String
TName = Range("N5").Value
If Application.Dialogs(xlDialogSaveAs).Show("Test Sheet for " & TName) Then
MsgBox "File saved as: " & ThisWorkbook.Name
Else
MsgBox "File not saved"
End If
End Sub
Bookmarks