View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Cesar Zapata[_2_] Cesar Zapata[_2_] is offline
external usenet poster
 
Posts: 66
Default Excel main window close event

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


"Avneesh Saxena" wrote in message
...
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