Disable Close "X" button on User Forms

C

Celtic_Avenger

Hope someone can help.

I have created a userform as a navigation menu for a very large
spreadsheet.
This Userform is sized to full screen, and all control buttons on the
User form lead to other full screen User forms.
The spreadsheet sheets simply operate and collate information entered
into the User forms in the background.

To ensure that the Userforms cannot be closed to give easy visible
access to the spreadsheet below, I would like to be able to disable the
"X" close button on the user form.

Is this possible.

Thanks for any help you can give.

Celtic_Avenger
 
R

Ron de Bruin

Hi Celtic

You can use this event in the userform module

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode <> vbFormCode Then
MsgBox "Use the Close button to close the form.", _
vbOKOnly, "yourprogramname"
Cancel = True
End If
End Sub
 
J

Jorge Rodrigues

Hi,
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
Jorge
 

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

Top