Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Userform Close button

Hello,
created a Userfrom, and noticed that it shows the Close
button (X), in the upper right top. Is there a way to
disable this? Or maybe add a code that if user clicks on
it, to get a message?
I know that in the properties one can show/hide the what's
this icon. So looking somethign for the Close ICON.

Any help would be appreciated.

thanks,

Juan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Userform Close button

put this in your code

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode A
Integer)
Cancel = 1
End Sub

this will stop the user from closing the userform

Phonio:cool

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform Close button

Hello,
where exactly do i do this?
I have a button, when I click this it opens the Userfrom.
In the button I have the following:
Private Sub CommandButton2_Click()
UserForm1.Show
End Sub
I tried to incorporate your code but doesn't open the
form.

Please advise thanks,
juan
-----Original Message-----
put this in your code

Private Sub UserForm_QueryClose(Cancel As Integer,

CloseMode As
Integer)
Cancel = 1
End Sub

this will stop the user from closing the userform

Phonio


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Userform Close button

Juan,

This is just another event so paste it in the form module at the end.

But be careful, the code provided will never let you close the form. There
are 4 close generating events, and you should only cancel at most 3. In your
case, I think you only need to use one, like so

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Select Case CloseMode
Case vbFormControlMenu: '0 user chosen Close command from Control
menu on the UserForm
Cancel = -1
Case vbFormCode: '1 unload statement is invoked from code.
Case vbAppWindows: '2 current Windows operating environment
session is ending.
Case vbAppTaskManager: '3 Windows Task Manager closing the
application
End Select

End Sub





Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Juan" wrote in message
...
Hello,
where exactly do i do this?
I have a button, when I click this it opens the Userfrom.
In the button I have the following:
Private Sub CommandButton2_Click()
UserForm1.Show
End Sub
I tried to incorporate your code but doesn't open the
form.

Please advise thanks,
juan
-----Original Message-----
put this in your code

Private Sub UserForm_QueryClose(Cancel As Integer,

CloseMode As
Integer)
Cancel = 1
End Sub

this will stop the user from closing the userform

Phonio


---
Message posted from http://www.ExcelForum.com/

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform Close button

First off want to thank all of you you provided me with
help.

I used the following:
Private Sub UserForm_QueryClose(Cancel As Integer,
CloseMode As Integer)
Select Case CloseMode
Case vbFormControlMenu
Cancel = -1
End Select
This works since it doesnt' close the form so user must
click O.K or the cancel button.

Once again thanks,

Juan
-----Original Message-----
Juan,

This is just another event so paste it in the form module

at the end.

But be careful, the code provided will never let you

close the form. There
are 4 close generating events, and you should only cancel

at most 3. In your
case, I think you only need to use one, like so

Private Sub UserForm_QueryClose(Cancel As Integer,

CloseMode As Integer)
Select Case CloseMode
Case vbFormControlMenu: '0 user chosen Close

command from Control
menu on the UserForm
Cancel = -1
Case vbFormCode: '1 unload statement is

invoked from code.
Case vbAppWindows: '2 current Windows

operating environment
session is ending.
Case vbAppTaskManager: '3 Windows Task Manager

closing the
application
End Select

End Sub





Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Juan" wrote in message
...
Hello,
where exactly do i do this?
I have a button, when I click this it opens the

Userfrom.
In the button I have the following:
Private Sub CommandButton2_Click()
UserForm1.Show
End Sub
I tried to incorporate your code but doesn't open the
form.

Please advise thanks,
juan
-----Original Message-----
put this in your code

Private Sub UserForm_QueryClose(Cancel As Integer,

CloseMode As
Integer)
Cancel = 1
End Sub

this will stop the user from closing the userform

Phonio


---
Message posted from http://www.ExcelForum.com/

.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Userform Close button

You can use the form's QueryClose event to detect that the user clicked
the X and cancel it.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = 1
End If
End Sub


Juan wrote:
Hello,
created a Userfrom, and noticed that it shows the Close
button (X), in the upper right top. Is there a way to
disable this? Or maybe add a code that if user clicks on
it, to get a message?
I know that in the properties one can show/hide the what's
this icon. So looking somethign for the Close ICON.

Any help would be appreciated.

thanks,

Juan



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW to close a userform using a button CC Excel Discussion (Misc queries) 2 October 10th 08 02:06 PM
Userform close button AOU Excel Discussion (Misc queries) 4 September 21st 07 05:56 PM
Userform + close button Chip Smith Excel Discussion (Misc queries) 2 April 1st 06 09:35 AM
Close Button on Userform Jean-Paul Viel Excel Programming 0 September 20th 03 06:44 PM
Disable close button of Modeless Userform RB Smissaert Excel Programming 2 September 13th 03 09:46 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"