This is an interesting problem that can be reproduced with only 4 lines of code so I think it might be a bug, unless I am doing something wrong (Which is entirely possible).
To recreate the problem, execute the following steps.
1. Open a new workbook
2. Copy the following code into the ThisWorkbook object
Private Sub Workbook_BeforeClose(Cancel As Boolean)
UserResponse = MsgBox("You wanna to bail?", vbYesNo)
If UserResponse = vbNo Then
Cancel = True
End If
End Sub
3. Save the file
4. Click the X in the upper right corner of the SPREADSHEET to close it
5. It will ask "Wanna Bail?"
6. Answer 'No'
7. (It doesn't close as expected)
7. Click the X in the upper right corner of the SPREADSHEET again.
8. The spreadsheet closes without firing the event
Any insights?
Thanks!
To recreate the problem, execute the following steps.
1. Open a new workbook
2. Copy the following code into the ThisWorkbook object
Private Sub Workbook_BeforeClose(Cancel As Boolean)
UserResponse = MsgBox("You wanna to bail?", vbYesNo)
If UserResponse = vbNo Then
Cancel = True
End If
End Sub
3. Save the file
4. Click the X in the upper right corner of the SPREADSHEET to close it
5. It will ask "Wanna Bail?"
6. Answer 'No'
7. (It doesn't close as expected)
7. Click the X in the upper right corner of the SPREADSHEET again.
8. The spreadsheet closes without firing the event
Any insights?
Thanks!