excel vba - how to disable userform close button "x"?

  • Thread starter Thread starter chief
  • Start date Start date
C

chief

is there a way to disable the close button on a userform such as
password screen that would disable a person from being able to clos
the userform by hitting the x button in the top right. I have it se
up so that they have to enter a password to view the page, bu
overlloked the fact that they can simply hit the close button. An
ideas
 
Hi,

Use the form's QueryClose Method

Here is the (pasted) example from the Excel VBA Help file

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If CloseMode <> 1 Then Cancel = 1
UserForm1.Caption = "The Close box won't work! Click me!"
End Sub

Look at the help file for more details

Regards

Paul
 
Back
Top