The Dutchman
Board Regular
- Joined
- Apr 10, 2008
- Messages
- 72
I am attempting to force a workbook user to close the workbook using a command button; I've disabled the use of the X button in the top right hand corner of the applicationby using the following code:
The problem is that when the button is clicked to save and close the workbook, the beforeclose script is run again and I cannot exit.
How can I work my way around this? Do I need to incorporate a public variable?
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "Please go to the Main Menu and use the 'Exit Promo System' button provided.", vbCritical, "Closing Promo System"
End Sub
The problem is that when the button is clicked to save and close the workbook, the beforeclose script is run again and I cannot exit.
How can I work my way around this? Do I need to incorporate a public variable?
Last edited: