Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default spinbutton enabled = false not changing colour

Using Excel 2003.
Have a Userform with many controls.
When doing enabled = false for all commandbuttons and spinbuttons, the
command buttons get greyed out, but the spinbuttons are not.
The code is like this:

Sub DisableAllControls()


Dim ctl As MSForms.Control


For Each ctl In MainForm.Controls
If TypeOf ctl Is MSForms.CommandButton Or _
TypeOf ctl Is MSForms.SpinButton Then
ctl.Enabled = False
End If
Next


End Sub


But even when I just set one individual spinner the result is the same.
They are actually disabled, but they just keep showing as normal. I have
tried to correct this with DoEvents and Userform.Repaint and using the Sleep
API function, but to no avail.
Would there be any solution for this other than doing Visible = False?
When do exactly the same on a little demo form all is fine.
Thanks for any advice.


RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default spinbutton enabled = false not changing colour

Hi RB

Can't reproduce the error here, your code works fine.
What is "many controls" ? If that is 200 some, then my experience is that
userforms may get unstable.

HTH. Best wishes Harald

"RB Smissaert" skrev i melding
...
Using Excel 2003.
Have a Userform with many controls.
When doing enabled = false for all commandbuttons and spinbuttons, the
command buttons get greyed out, but the spinbuttons are not.
The code is like this:

Sub DisableAllControls()


Dim ctl As MSForms.Control


For Each ctl In MainForm.Controls
If TypeOf ctl Is MSForms.CommandButton Or _
TypeOf ctl Is MSForms.SpinButton Then
ctl.Enabled = False
End If
Next


End Sub


But even when I just set one individual spinner the result is the same.
They are actually disabled, but they just keep showing as normal. I have
tried to correct this with DoEvents and Userform.Repaint and using the

Sleep
API function, but to no avail.
Would there be any solution for this other than doing Visible = False?
When do exactly the same on a little demo form all is fine.
Thanks for any advice.


RBS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default spinbutton enabled = false not changing colour

It is over 200 controls.
Apart from this everything else works fine.
It isn't really a major problem as the spinners are disabled
and I can set the backcolor, but I would like to fix if possible.

RBS

"Harald Staff" wrote in message
...
Hi RB

Can't reproduce the error here, your code works fine.
What is "many controls" ? If that is 200 some, then my experience is that
userforms may get unstable.

HTH. Best wishes Harald

"RB Smissaert" skrev i melding
...
Using Excel 2003.
Have a Userform with many controls.
When doing enabled = false for all commandbuttons and spinbuttons, the
command buttons get greyed out, but the spinbuttons are not.
The code is like this:

Sub DisableAllControls()


Dim ctl As MSForms.Control


For Each ctl In MainForm.Controls
If TypeOf ctl Is MSForms.CommandButton Or _
TypeOf ctl Is MSForms.SpinButton Then
ctl.Enabled = False
End If
Next


End Sub


But even when I just set one individual spinner the result is the same.
They are actually disabled, but they just keep showing as normal. I have
tried to correct this with DoEvents and Userform.Repaint and using the

Sleep
API function, but to no avail.
Would there be any solution for this other than doing Visible = False?
When do exactly the same on a little demo form all is fine.
Thanks for any advice.


RBS




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default spinbutton enabled = false not changing colour

Try again, but now when the spinbutton has a backcolor set before doing
Enable = False.
I picked this backcolor: 15001309, but may not matter.
So, this trouble is caused by the backcolor being set, not anything else.
Note that the commandbutton doesn't have this problem.

RBS

"Harald Staff" wrote in message
...
Hi RB

Can't reproduce the error here, your code works fine.
What is "many controls" ? If that is 200 some, then my experience is that
userforms may get unstable.

HTH. Best wishes Harald

"RB Smissaert" skrev i melding
...
Using Excel 2003.
Have a Userform with many controls.
When doing enabled = false for all commandbuttons and spinbuttons, the
command buttons get greyed out, but the spinbuttons are not.
The code is like this:

Sub DisableAllControls()


Dim ctl As MSForms.Control


For Each ctl In MainForm.Controls
If TypeOf ctl Is MSForms.CommandButton Or _
TypeOf ctl Is MSForms.SpinButton Then
ctl.Enabled = False
End If
Next


End Sub


But even when I just set one individual spinner the result is the same.
They are actually disabled, but they just keep showing as normal. I have
tried to correct this with DoEvents and Userform.Repaint and using the

Sleep
API function, but to no avail.
Would there be any solution for this other than doing Visible = False?
When do exactly the same on a little demo form all is fine.
Thanks for any advice.


RBS




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default spinbutton enabled = false not changing colour

"RB Smissaert" skrev i melding
...
Try again, but now when the spinbutton has a backcolor set before doing
Enable = False.
I picked this backcolor: 15001309, but may not matter.
So, this trouble is caused by the backcolor being set, not anything else.
Note that the commandbutton doesn't have this problem.


I see. That makes kinda sense.
But "don't" then <g. Some things in life doesn't combine and we usually
have to live with that.
Thank you for the insight though. We live and we learn.

Best wishes Harald




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default spinbutton enabled = false not changing colour

I need the backcolor, but doing:
ctl.ForeColor = vbButtonShadow
simulates a disabled state and that is good enough in my case.
Still, always interested in a better solution.

RBS

"Harald Staff" wrote in message
...
"RB Smissaert" skrev i melding
...
Try again, but now when the spinbutton has a backcolor set before doing
Enable = False.
I picked this backcolor: 15001309, but may not matter.
So, this trouble is caused by the backcolor being set, not anything else.
Note that the commandbutton doesn't have this problem.


I see. That makes kinda sense.
But "don't" then <g. Some things in life doesn't combine and we usually
have to live with that.
Thank you for the insight though. We live and we learn.

Best wishes Harald



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default spinbutton enabled = false not changing colour

Ah! Clever workaround. Thanks.

Best wishes Harald

"RB Smissaert" skrev i melding
...
I need the backcolor, but doing:
ctl.ForeColor = vbButtonShadow
simulates a disabled state and that is good enough in my case.
Still, always interested in a better solution.

RBS



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default spinbutton enabled = false not changing colour

Strangely, if you do:
ctl.Enabled = False
ctl.ForeColor = vbButtonShadow

the ForeColor won't be vbButtonShadow.

Same if you do:
ctl.ForeColor = vbButtonShadow
ctl.Enabled = False

RBS


"Harald Staff" wrote in message
...
Ah! Clever workaround. Thanks.

Best wishes Harald

"RB Smissaert" skrev i melding
...
I need the backcolor, but doing:
ctl.ForeColor = vbButtonShadow
simulates a disabled state and that is good enough in my case.
Still, always interested in a better solution.

RBS




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
Changing background colour when changing data in a cell Paoul Excel Discussion (Misc queries) 7 December 26th 08 07:25 AM
how to change colour of text in true or false formula linda Excel Worksheet Functions 1 August 23rd 05 09:58 AM
Changing the SpinButton value in Workbook_Open() Tony Steane Excel Programming 4 January 15th 05 11:36 PM
looping through userform controls changing enabled and locked properties JulieD Excel Programming 2 August 14th 04 12:44 PM
spinbutton.enabled = false not greying out RB Smissaert Excel Programming 4 December 22nd 03 12:31 AM


All times are GMT +1. The time now is 11:11 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"