E
Ed Davis
I am trying to make sure the workbook is saved in case the user X's out of
excel.
I have macros that save the workbooks if they exit properly but have found
they sometimes
X out of excel and do not save the changes.
I have put the following code in the thisworkbook module.
What happens is if they exit properly Excel stays open and the workbook
never closes, when exiting properly it should shut down excel which I have
the macro doing correctly before this code was put in.
I do get the message that the workbook was saved and will close.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Saved = True Then
MsgBox "Saved Will Close"
Else
MsgBox "Not Saved Will Save"
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
End If
End Sub
excel.
I have macros that save the workbooks if they exit properly but have found
they sometimes
X out of excel and do not save the changes.
I have put the following code in the thisworkbook module.
What happens is if they exit properly Excel stays open and the workbook
never closes, when exiting properly it should shut down excel which I have
the macro doing correctly before this code was put in.
I do get the message that the workbook was saved and will close.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Saved = True Then
MsgBox "Saved Will Close"
Else
MsgBox "Not Saved Will Save"
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
End If
End Sub