I have written a code in excel that save as excel file in another location when user clicks save button.
I put the code in this workbook of personal.xlsb
Private WithEvents App As Application
Private Sub Workbook_Open()
Set App = Application
Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim strFileA, strFileB
strFileA = ActiveWorkbook.Name
Application.DisplayAlerts = False
'Define backup path shown in blue below
strFileB = "C:\backup\excelnew\" & strFileA
Application.DisplayAlerts = True
But when I open an excel file(Not new) and apply some changes and then when i want to save it , I get an error : microsoft excel has stopped working
And I should close the file.
Would you please tell me why this problem happen?