Disabling Cancel in a user form

M

Mike H

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
 
D

Dave Peterson

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.
 

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