我有一个 VBA 代码,它强制另存为对话框在尝试保存 xltm 时将默认另存为类型显示为 xlsm。请查看随附的代码,如果代码不正确,请纠正我
Application.EnableEvents = False
Application.DisplayAlerts = False
If SaveAsUI = True Then
bInProcess = True
'The following statements shows the save as dialog box with default path
Set FileSaveName = Application.FileDialog(msoFileDialogSaveAs)
FileSaveName.InitialFileName = ThisWorkbook.Name
FileSaveName.FilterIndex = 2 'select to save with a ".xlsm" extension
FileSaveName.Title = "Save As"
intchoice = FileSaveName.Show
If intchoice = 0 Then
Else
FileSaveName.Execute
End If
Else 'Normal Save
bInProcess = True
Cancel = True
ThisWorkbook.Save
End If
Application.EnableEvents = True
Application.DisplayAlerts = True
上面的代码在尝试使用 (ctrl+s) 保存时工作正常。如果我试图通过 excel 关闭窗口选项关闭。Excel 显示默认的另存为弹出窗口。如果我从该另存为弹出窗口中单击“保存”选项,则不会调用 workbook_beforesave 事件(显示另存为对话框,默认数据类型从 xlsm 更改为 xls)。我不知道我犯了什么错误?请帮我摆脱这个..
提前致谢!!!