Make a user form 'un-closeable'

  • Thread starter Thread starter peekbo
  • Start date Start date
P

peekbo

So now that I figured out how to work underneath a user form - how can
make the box uncloseable?

i.e. Everytime you try to click the 'x' - it displays cannot close
 
Ok,

Now you have to add "Done" Button if you want to get rid of th
userform othewise it will always be there. But here is something tha
will cancel the "X". The "X" will still show but when clicked it wil
not close the form.

Heres the code for it.

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, closemode A
Integer)
If closemode = vbFormControlMenu Then
Cancel = True
End If
End Sub

HTH

Charle
 
Insert the following in your form code:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim vbResponse As VbMsgBoxResult
vbResponse = MsgBox("Do you want to close this form?", vbYesNo)
If vbResponse = vbNo Then Cancel = True
End Sub

Regards,
Andrew
 

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