我有一个宏模板文件。它显示保存为对话框" .xls"格式为默认值。我想将默认类型显示为" .xlsm"。我需要使用vba来做到这一点。
请有人帮我解决这个问题。
提前致谢!!!
答案 0 :(得分:0)
请参阅以下代码。它对我有用!!
Dim FileSaveAsName As Variant, intchoice As Integer
Static saveProcess As Boolean
If Not saveProcess Then
Application.EnableEvents = False
Application.DisplayAlerts = False
If SaveAsUI = True Then 'Save As... was selected
saveProcess = True
Set FileSaveName = Application.FileDialog(msoFileDialogSaveAs)
FileSaveName.InitialFileName = ThisWorkbook.Name
FileSaveName.FilterIndex = 2 'select to save with a ".xlsm" extension
intchoice = FileSaveName.Show
If intchoice <> 0 Then
FileSaveName.Execute
End If
Cancel = True
Else 'Normal Save
saveProcess = True
Cancel = True
ThisWorkbook.Save
End If
saveProcess = False
Application.EnableEvents = True
Application.DisplayAlerts = True
End If