I have a VBA Code which forced the save as dialog box to show the default save as type as xlsm while trying to save a xltm. Please check out the attached code and correct me if code is incorrect
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
The above code works fine while trying to save using (ctrl+s). If I tried to close through excel close window option. Excel shows default save-as pop-up. If I click "Save" option from that save as pop-up , workbook_beforesave event is not invoked(Save As dialog is shown with default data type changed to xls from xlsm). I don't know what mistake I made? Please help me to get rid of this..
Thanks in advance!!!