我有这行代码将工作表复制到新工作簿:
OrderForm.Copy ' copy worksheet to new workbook
我很好,如果它在标题栏上显示为Book n 并且我不想自动保存它,但我想要的是有一个默认名称(也默认为.xlsx)当用户决定保存它时,如下所示:
答案 0 :(得分:1)
使用BeforeSave事件捕获用户保存,然后使用初始值显示您自己的对话框(如此):
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