Canceling a UserForm

E

Eric W.

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
 
R

Rob Bovey

Eric W. said:
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 *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top