MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

userform question

  Asked By: Jimmy    Date: Dec 13    Category: MS Office    Views: 1602

You can close a userform by clicking on the X on the very right of header rather
than using a button in the form. How can I disable this, and force the user to
only exit a form by using one of the buttons?



4 Answers Found

Answer #1    Answered By: Rose Hughes     Answered On: Dec 13

Like this:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close  the dialog like this!"
End If
End Sub

Answer #2    Answered By: Jessica Brown     Answered On: Dec 13

An additonal question: How can I disable  this button  in a MsgBox?

Answer #3    Answered By: Tia Hughes     Answered On: Dec 13

Not sure you can. But you could make it an input box and test on exit
for a null input. Just a thought.

Answer #4    Answered By: Zachary Bouchard     Answered On: Dec 13

You can use "terminate" event,

example, your FormName : UserForm1

write this program on terminate event :

Private Sub UserForm_Terminate()
End Sub

even user  click the X on the very right of header, userform1 is still show up.

for the "END"/exit button, example : commandButton1,

Private Sub CommandButton1_Click()
End Sub

Now, we can force  user by using CommandButton1 to exit  !

Didn't find what you were looking for? Find more on userform question Or get search suggestion and latest updates.