Disabling Cancel in a user form

  • Thread starter Thread starter Barb Reinhardt
  • Start date Start date
Barb,

I may be having an elderly moment but userforms (Excel 2003) don't have a
cancel option unless the user puts a button there. What are you tring to
prevent the cancelling of?

If you mean the big red cross then this prevents a userform being cancelled
with that

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Leave that cross alone"
End If
End Sub

Mike
 
You mean the top right X?

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
msgbox "Don't use that X"
cancel = true
End If
End Sub

But I would think it would be much more standard to let the user click the X.
If there's some code that needs to run if the user cancels, then have this
routine call the BTNCancel_click procedure.
 
Back
Top