ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel main window close event (https://www.excelbanter.com/excel-programming/283275-excel-main-window-close-event.html)

Avneesh Saxena

Excel main window close event
 
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



Cesar Zapata[_2_]

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





Avneesh Saxena

Excel main window close event
 
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

"Cesar Zapata" wrote in message
...
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








All times are GMT +1. The time now is 04:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com