Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Handling Dialog Boxes

Hello,

Is there an easy way to disable close-button (that X in upper right corner)
in dialog boxes or any easy way to handle a case when user clicks it?

And an other question. How can I disable OnChange-event to execute, when I
set up the values on a dialog box?

Thank You for Your answers.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Handling Dialog Boxes

If you are referring to userforms then you can handle the user clicking
large X by including the QueryClose event

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub

The above simply ignores the user pressing large X; if you wish to disable
or remove the status bar altogether then you will need to include an API
call, if you need this repost for more information.

To disable events use Application.EnableEvents = False
after updating re-enable them with Application.EnableEvents = True

--
Cheers
Nigel



"djExcel" wrote in message
...
Hello,

Is there an easy way to disable close-button (that X in upper right
corner)
in dialog boxes or any easy way to handle a case when user clicks it?

And an other question. How can I disable OnChange-event to execute, when I
set up the values on a dialog box?

Thank You for Your answers.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Handling Dialog Boxes

Let me add some information on the suppression of events.

Using the same assumption, that the OP is talking about Userforms, then
application.EnableEvents has no effect on events for Control Toolbox Controls
used on the userform and their related events (those in the Userform module).
Application.EnableEvents is part of the Excel library. Control Toolbox
controls are part of the MSforms library. There is no single command to
disable these events. You have to program each event to look at specific
conditions and avoid running any inappropriate code if the conditions so
warrant.

If the OP was actually talking about Excel events such as worksheet_change,
then you are absolutely correct that that the enableevents command will
suppress these.

--
Regards,
Tom Ogilvy

"Nigel" wrote:

If you are referring to userforms then you can handle the user clicking
large X by including the QueryClose event

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub

The above simply ignores the user pressing large X; if you wish to disable
or remove the status bar altogether then you will need to include an API
call, if you need this repost for more information.

To disable events use Application.EnableEvents = False
after updating re-enable them with Application.EnableEvents = True

--
Cheers
Nigel



"djExcel" wrote in message
...
Hello,

Is there an easy way to disable close-button (that X in upper right
corner)
in dialog boxes or any easy way to handle a case when user clicks it?

And an other question. How can I disable OnChange-event to execute, when I
set up the values on a dialog box?

Thank You for Your answers.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Handling Dialog Boxes

Hi Tom
Your clarification will help the OP who I suspect is talking about userform
events. So the suggestion would be to have conditional statements in the
OnChange events of controls on the userform code where, if in edit mode, the
event when triggered is ignored otherwise it the event runs normally.

Private Sub ComboBox1_Change()

If eMode = True Then Exit Sub

' code here runs if not in edit mode

End Sub

Variable eMode is set to True before the control is updated; and set False
afterwards.

--
Cheers
Nigel



"Tom Ogilvy" wrote in message
...
Let me add some information on the suppression of events.

Using the same assumption, that the OP is talking about Userforms, then
application.EnableEvents has no effect on events for Control Toolbox
Controls
used on the userform and their related events (those in the Userform
module).
Application.EnableEvents is part of the Excel library. Control Toolbox
controls are part of the MSforms library. There is no single command to
disable these events. You have to program each event to look at specific
conditions and avoid running any inappropriate code if the conditions so
warrant.

If the OP was actually talking about Excel events such as
worksheet_change,
then you are absolutely correct that that the enableevents command will
suppress these.

--
Regards,
Tom Ogilvy

"Nigel" wrote:

If you are referring to userforms then you can handle the user clicking
large X by including the QueryClose event

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub

The above simply ignores the user pressing large X; if you wish to
disable
or remove the status bar altogether then you will need to include an API
call, if you need this repost for more information.

To disable events use Application.EnableEvents = False
after updating re-enable them with Application.EnableEvents = True

--
Cheers
Nigel



"djExcel" wrote in message
...
Hello,

Is there an easy way to disable close-button (that X in upper right
corner)
in dialog boxes or any easy way to handle a case when user clicks it?

And an other question. How can I disable OnChange-event to execute,
when I
set up the values on a dialog box?

Thank You for Your answers.






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
Dialog Boxes stacy05 Excel Discussion (Misc queries) 8 February 5th 08 02:02 AM
dialog boxes Dave F Excel Discussion (Misc queries) 5 August 24th 06 10:03 PM
Dialog Boxes naiveprogrammer Excel Discussion (Misc queries) 2 October 18th 05 10:30 PM
Handling Combo boxes... sujeshn Excel Programming 1 July 15th 05 12:25 PM
Dialog boxes webster Excel Discussion (Misc queries) 5 July 9th 05 11:16 AM


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

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"