ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Canceling a UserForm (https://www.excelbanter.com/excel-programming/275350-canceling-userform.html)

Eric W.

Canceling a UserForm
 
How can I capture the event (if there is one) of a user
clicking the "X" at the upper right of a UserForm? I want
my workbook to save when this happens. It's driving me
crazy!!! Help!!!

Eric W.
Madison, WI

Rob Bovey

Canceling a UserForm
 
"Eric W." wrote in message
...
How can I capture the event (if there is one) of a user
clicking the "X" at the upper right of a UserForm? I want
my workbook to save when this happens. It's driving me
crazy!!! Help!!!


Hi Eric,

When the user clicks the X close button on a UserForm the UserForm's
QueryClose event is fired.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
''' User clicked the X close button.
End If
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *




All times are GMT +1. The time now is 12:00 AM.

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