SIMPLEST way to disable "close" button on form?
cody,
You can place the following code into each of the
UserForms:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
' Disable the "X" on the userform so that the user can't
' dismiss the userform by clicking on the "X" in the upper
' right hand corner of the userform
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox Prompt:="Please use the buttons on the" & vbCrLf & _
" Form to Close it"
End If
End Sub
The above will still allow the user to break out if the code with
the Ctrl + Break key.
The following code (in the Workbook_Open Event or a regular
sub called before you open the UserForm) will cure that:
Application.EnableCancelKey = xlDisabled
John
codytheretriever wrote:
Have 10 forms in an Excel based
project. On eight of the forms
I need to disable "close" button
and double-click capability so
that user must only go in directions
allowed by form command buttons.
On the other two forms using "close"
or double-click is ok. Have tried
all of the Knowledge Base suggestions
but keep getting compile errors for
"ambiguous ... blah ... blah ... blah",
NOT due to typing errors! Could someone
give me SIMPLE directions on how to
disable "close" button on a form by
form basis? Hope someone can help,
and thanks in advance if you can.
|