Excel main window close event

  • Thread starter Thread starter Avneesh Saxena
  • Start date Start date
A

Avneesh Saxena

Can I somehow get a notification when the user tries to close the excel
application? Say, I just want to pop open a message box asking user if she
indeed wants to exit.

Thanks,
--Avs
 
Avneesh.


I really would not recommend to do it cause it is annoying. Because I know I
want to close when I click the X button I dont like to be asked if I wanna
do it


either way if you still think is a good Idea or have a special project then
use this.


Private Sub Workbook_BeforeClose(Cancel As Boolean)

myans = MsgBox("Are you sure you wanna get out of here?", vbYesNo)
If myans = vbNo Then
Exit Sub
Else
Application.Quit
End If

End Sub

Regards,

Cesar Zapata
 
Thanks! However, I don't want to trap workbook close events but I want to
trap the closing of the main window (which is obviously different).

lso, I'm not going to popup a dialog but I do want to make some programatic
changes, that was just the simplest way to put it :-).

Thanks,
--Avs
 
Back
Top