disable the "close" cross

jimmywanna

Board Regular
Joined
Mar 18, 2002
Messages
182
Is it possible to disable the cross which closes a user form.
I have searched through and fiddled with the properties but nothing seems to work.

any ideas?

jim
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi jim,

Try this:
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "You can't do that!"
    End If
End Sub
Look-up QueryClose in the VBE Help for full details.

HTH
 
Upvote 0
You can use the CloseMode parameter in the userform's QueryClose event to handle this. The code below will prevent the form from closing via the 'X', but remember to add a button to do the closing... :biggrin:

Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode <> 1 Then
    MsgBox "You must use the close button"
    Cancel = True
End If

End Sub
 
Upvote 0
Thanks Chap's.
That works a treat, but it doesn't solve my problem as i thought it might.

From my other thread, a macro runs after the password is entered, whether the pass word is wrong or right it still unhides some columns, this then allows the user to type into cells which i didn't want unhidden unless the password was right.

Private Sub CommandButton1_Click()

Const Password As String = "PRESLEY" ' Case sensitive
Dim Pass As String, Msg As String
Dim Ans As Integer

Msg = "Wrong Password" & vbCrLf & "Try Again ?"
Pass = TextBox1.Text

If Pass = "" Then ActiveWorkbook.Close SaveChanges:=False

If Pass <> "PRESLEY" Then
Ans = MsgBox(Msg, vbCritical + vbYesNo, "Password")
If Ans = vbNo Then
ActiveWorkbook.Close SaveChanges:=False
Else
TextBox1.Text = ""
TextBox1.SetFocus
End If
Else
Unload Me
End If
Columns("B:J").Select
Selection.EntireColumn.Hidden = False
Range("E2:F2").Select
End Sub


I thought that by disabling the cross, the password would have to be entered correctly to allow the sheet behind the userform to be typed on, this isn't the case.

this is driving me crazy now

any help guy's, PLEASE!!!!!!!!!

:oops:

jim
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top