I want to program Excel to create back-up of my file before saving it.
But each time I am trying to use it, Excel crashes.
Can please some explain me why this happens even if I insert Application.EnableEvents = False
to prevent infinite loop?
The code I am using is below:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & "BackUp_" & Date & "_" & ActiveWorkbook.Name, FileFormat:=52
Application.EnableEvents = True
End Sub
Thank you in advance for help!