Please refer the following code. It works for me!!
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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…