Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default controlbox property?

I need to keep the user from using the red x on a userform to close the form.
I found several mentions of a controlbox property. It is not listed under
the properties of the form.

Where do I set this when the form is displayed?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default controlbox property?

I found this in the archives. Maybe it will help.

Dan

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


Juan
More options May 6 2004, 12:47 pm
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

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


Steve Garman

Date: Thu, 06 May 2004 21:04:16 +0100
Local: Thurs, May 6 2004 1:04 pm
Subject: 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

Bob Phillips

From: "Bob Phillips"
Date: Thu, 6 May 2004 21:36:20 +0100
Local: Thurs, May 6 2004 1:36 pm
Subject: 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
From: "Juan"
Date: Thu, 6 May 2004 14:15:27 -0700
Local: Thurs, May 6 2004 2:15 pm
Subject: 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default controlbox property?

You mean the top right X?

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
msgbox "Don't use that X"
cancel = true
End If
End Sub

But I would think it would be much more standard to let the user click the X.
If there's some code that needs to run if the user cancels, then have this
routine call the BTNCancel_click procedure.

dawall33 wrote:

I need to keep the user from using the red x on a userform to close the form.
I found several mentions of a controlbox property. It is not listed under
the properties of the form.

Where do I set this when the form is displayed?


--

Dave Peterson
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
Controlbox - Form Control - ActiveX CousinExcel Excel Discussion (Misc queries) 1 March 20th 10 12:16 PM
Runtime error 380 - Could not set the list property. Invalid property value. [email protected] Excel Programming 3 February 27th 07 06:35 AM
Can I change a controlbox to a listbox on a Form Post Tenebras Lux Excel Programming 5 August 10th 06 06:36 PM
Runtime Error 380 – Could not set the list property. Invalid property value BernzG[_16_] Excel Programming 2 August 21st 05 10:10 PM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Excel Programming 0 October 6th 04 09:28 PM


All times are GMT +1. The time now is 02:47 PM.

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

About Us

"It's about Microsoft Excel"