Disable UserForm 'X' Close Button

  • Thread starter Thread starter dimm
  • Start date Start date
D

dimm

Hi again,

I hope everyone is keeping well.

I'm wondering if there is any way to disable or remove the X button on the
top right of a UserForm?
 
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Exit Sub
End If
End Sub
 
Instead of just canceling, why not have it run the code in your cancel
button. That's why the user clicked the X anyway, right?

Assuming the cancel button is named btnCancel:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
btnCancel
End If
End Sub

- Jon
 
Back
Top