Hello,
I have a macro enabled template workbook and I would like it to force the user to save the file as a macro-enabled workbook.
I have found the following code and copied it into the 'This Workbook' module but it's still saving as a Excel Workbook file.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim FileNameVal As String
If SaveAsUI Then
FileNameVal = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm")
Cancel = True
If FileNameVal = "False" Then 'User pressed cancel
Exit Sub
End If
ThisWorkbook.SaveAs FileName:=FileNameVal & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.EnableEvents = True
End If
End Sub
Any help would be greatly appreciated!
Thank you!
Bookmarks