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
 

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

Back
Top