Reputation: 437
I have this line of code that copies a worksheet to a new workbook:
OrderForm.Copy ' copy worksheet to new workbook
The new workbook shows up as Bookn.xlsx:
When saving this is what shows up:
I'm okay if it shows up as Bookn on the title bar and I don't want to automatically save it, but what I want is to have a default name (also default to .xlsx) when the user decides to save it, like this:
Upvotes: 0
Views: 193
Reputation: 1081
Use the BeforeSave event to capture the user saving, then show your own dialog with an initial value (like so):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim fName As String
Cancel = True
fName = Application.GetSaveAsFilename("Default Name", _
"Excel Workbook (*.xlsx), *.xlsx," & _
"Macro Enabled Workbook (*.xlsm), *xlsm")
ThisWorkbook.SaveAs fName
End Sub
Upvotes: 1