Thread: Userform Cancel
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default Userform Cancel

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button to close the form", vbInformation

End If
End Sub
xxxxxxxxxxxxxxxxx
i don't need this, usually, but somebody posted it once & i snatched it
"in case".
susan


Hank Youngerman wrote:
I am always amazed at how I can't find answers to the simplest
questions.

I am loading a userform. The form has the normal "close" box in the
upper right corner.

It appears that if that box is clicked, the form unloads. This can
cause some problems with my later program flow. I have an "exit" box
on the form itself, but that lets me run some code.

How do I capture the event where the user clicks the "x" to close the
form? I have events like workbook_beforeclose but I can't find a
similar event for a form. Alternatively, how do I eliminate the close
box from the form, so that the user has to click on "exit?"