Hi.
I am trying to force the users of an excel file to Save it as a macro enabled workbook. I can do this fine. However, I still want the ability to be able to edit the template. So I need a way to either only allow me to save it as a template or simply to force users to save it as either a macro-enabled workbook OR a macro-enabled template.
This is the code I currently have (entered in the "ThisWorkbook" Section of the VBAProject):
Any help would be much appreciated
I am trying to force the users of an excel file to Save it as a macro enabled workbook. I can do this fine. However, I still want the ability to be able to edit the template. So I need a way to either only allow me to save it as a template or simply to force users to save it as either a macro-enabled workbook OR a macro-enabled template.
This is the code I currently have (entered in the "ThisWorkbook" Section of the VBAProject):
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim fName As String
fName = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm")
If fName = "False" Then
MsgBox "You pressed cancel", vbOKOnly
Cancel = True
End If
Application.EnableEvents = False
ThisWorkbook.SaveAs Filename:=fName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.EnableEvents = True
End Sub
Any help would be much appreciated