Results 1 to 2 of 2
2012-11-12, 10:38 #1
- Join Date
- Nov 2002
- London, Gtr London, England
- Thanked 0 Times in 0 Posts
Close routine, cancel close and return to spreadsheet
If I have a close event and offer the user the opportunity to cancel (the close) how do i quit the routine and stop the close to return to the spreadsheet? I want to use vbYesNoCancel where Yes will do update a date, save and exit, No will save & exit and Cancel will return to the spreadsheet.
Thank you....................... liz
Last edited by lizat; 2012-11-12 at 10:46.
2012-11-12, 14:51 #2
- Join Date
- Mar 2004
- Manning, South Carolina
- Thanked 1,456 Times in 1,325 Posts
Here's some code I use in Excel to trap the big red X and abort the close if the standard menubar is not visible.
Option Explicit Private Sub Workbook_BeforeClose(Cancel As Boolean) With Application If Not .CommandBars("Worksheet Menu Bar").Enabled Then MsgBox "Please use the Menu's to Exit the System" & vbCrLf & _ "Closing using the X will cause serious" & vbCrLf & _ "system problems!", vbOKOnly + vbCritical, _ "Error: Improper Attempt to Exit System" Cancel = True End If End With End Sub