ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable the Close button on a Userform (https://www.excelbanter.com/excel-programming/402756-disable-close-button-userform.html)

Moh

Disable the Close button on a Userform
 
how do i disable the close button on my userform?
or can i just remove it?

and when the user clicks cancel... is there a way to direct the user back to
sheet1 ?

Cheers
--


Carim

Disable the Close button on a Userform
 
Hi,

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
' make user do what you want"
Cancel = True
End If
End Sub

HTH

Moh

Disable the Close button on a Userform
 
where do i put this code?
--



"Carim" wrote:

Hi,

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
' make user do what you want"
Cancel = True
End If
End Sub

HTH


[email protected]

Disable the Close button on a Userform
 
On Dec 14, 2:32 pm, Moh wrote:
where do i put this code?
--



"Carim" wrote:
Hi,


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
' make user do what you want"
Cancel = True
End If
End Sub


HTH- Hide quoted text -


- Show quoted text -


Hi
Double click your form and paste it in (the code module behind the
form)
regards
Paul

Carim

Disable the Close button on a Userform
 
Open your form, hit F7 and copy code ...

merjet

Disable the Close button on a Userform
 
where do i put this code?

In the UserForm's code module.

Hth,
Merjet



Moh

Disable the Close button on a Userform
 
it doesn't work

pls help further
--



" wrote:

On Dec 14, 2:32 pm, Moh wrote:
where do i put this code?
--



"Carim" wrote:
Hi,


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
' make user do what you want"
Cancel = True
End If
End Sub


HTH- Hide quoted text -


- Show quoted text -


Hi
Double click your form and paste it in (the code module behind the
form)
regards
Paul


merjet

Disable the Close button on a Userform
 
What exactly do you mean by "it doesn't work"?

Maybe you need to add a Command Button with
the following code:

Private Sub CommandButton1_Click()
Sheet1.Activate
Unload Me
End Sub





All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com