Can you trap the Close button (red X) on a Userform?

  • Thread starter Thread starter rick
  • Start date Start date
R

rick

Is it possible to get an error code or an event when the user clicks on the
form close button?

Thanks.

... rick
 
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
msgbox "You clicked the X"
End If
End Sub
 
Back
Top