I have disabled the Save/Don'tSave/Cancel prompt that appears on closing the workbook by using
UserForm1 has Save/Don't Save/Cancel buttons so I can run a macro if they click Save. (If they click SAVE it saves the workbook and makes a time-stamped backup copy.
QUESTION: How do I make my Cancel button behave like a normal cancel button? That is to say, I want my Cancel button to just unload the userform but leave the workbook open. As it is now it behaves exactly like the Don'tSave button. The userform unloads and the workbook closes.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Call ProtectAllSheets
Call ResetAllSheets
Sheets(1).Activate
Application.GoTo Range("A1"), Scroll:=True
Range("A69").Select
Application.ScreenUpdating = True
[B]ThisWorkbook.Saved = True[/B]
If ThisWorkbook.ReadOnly = True Then GoTo Done
UserForm1.Show
Done:
End Sub
UserForm1 has Save/Don't Save/Cancel buttons so I can run a macro if they click Save. (If they click SAVE it saves the workbook and makes a time-stamped backup copy.
QUESTION: How do I make my Cancel button behave like a normal cancel button? That is to say, I want my Cancel button to just unload the userform but leave the workbook open. As it is now it behaves exactly like the Don'tSave button. The userform unloads and the workbook closes.
Last edited: