Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default change color of command button problem

Earlier I posted a message about this, but thought the problem had to do
with a timer loop. When the suggestions for fixes didn't help, I (after
about 3 hours of changing things around) discovered the following.
First the code: (The button just clicked and previous button clicked are
supposed to turn red, then after two seconds turn gray. The problem is only
the previously clicked button turns red. )
Public Sub BadChoice()
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Red
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Red
Application.Wait Now + TimeSerial(0, 0, 2)
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Gray
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Gray
End Sub
Now the "rest of the story": This procedure may get called depending on the
user clicking correctly on "Yes" or "No" in either a UserForm or a Msgbox.
(I've tried both userform and msgbox--and both create the problem.) IF I
leave the Userform or Msgbox where it first appears on the screen, then
everything works fine, BUT if I move either the Msgbox or UserForm, the
"no-red" problem happens. (I'm moving it because I'd like to have the
Userform or Msgbox appear at a specific location over the spreadsheet.)
Any suggestions why this is happening and how to fix it?
Thanks.
Bert


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default change color of command button problem

Bert,

I couldn't get the red at all, but I got this to work

Public Sub BadChoice()

With Worksheets(2).OLEObjects

.Item(FirstBtnNo).Object.BackColor = red
.Item(BtnNo).Object.BackColor = red
Application.OnTime Now + TimeSerial(0, 0, 5), "ResetChoice"
End With
End Sub

Public Sub ResetChoice()
With Worksheets(2).OLEObjects

.Item(BtnNo).Object.BackColor = gray
.Item(FirstBtnNo).Object.BackColor = gray
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Bert" wrote in message
...
Earlier I posted a message about this, but thought the problem had to do
with a timer loop. When the suggestions for fixes didn't help, I (after
about 3 hours of changing things around) discovered the following.
First the code: (The button just clicked and previous button clicked are
supposed to turn red, then after two seconds turn gray. The problem is
only the previously clicked button turns red. )
Public Sub BadChoice()
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Red
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Red
Application.Wait Now + TimeSerial(0, 0, 2)
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Gray
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Gray
End Sub
Now the "rest of the story": This procedure may get called depending on
the user clicking correctly on "Yes" or "No" in either a UserForm or a
Msgbox. (I've tried both userform and msgbox--and both create the
problem.) IF I leave the Userform or Msgbox where it first appears on the
screen, then everything works fine, BUT if I move either the Msgbox or
UserForm, the "no-red" problem happens. (I'm moving it because I'd like
to have the Userform or Msgbox appear at a specific location over the
spreadsheet.)
Any suggestions why this is happening and how to fix it?
Thanks.
Bert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default change color of command button problem

Bob:
That seemed to do the trick. Thanks

"Bob Phillips" wrote in message
...
Bert,

I couldn't get the red at all, but I got this to work

Public Sub BadChoice()

With Worksheets(2).OLEObjects

.Item(FirstBtnNo).Object.BackColor = red
.Item(BtnNo).Object.BackColor = red
Application.OnTime Now + TimeSerial(0, 0, 5), "ResetChoice"
End With
End Sub

Public Sub ResetChoice()
With Worksheets(2).OLEObjects

.Item(BtnNo).Object.BackColor = gray
.Item(FirstBtnNo).Object.BackColor = gray
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Bert" wrote in message
...
Earlier I posted a message about this, but thought the problem had to do
with a timer loop. When the suggestions for fixes didn't help, I (after
about 3 hours of changing things around) discovered the following.
First the code: (The button just clicked and previous button clicked are
supposed to turn red, then after two seconds turn gray. The problem is
only the previously clicked button turns red. )
Public Sub BadChoice()
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Red
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Red
Application.Wait Now + TimeSerial(0, 0, 2)
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackCo lor = Gray
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.B ackColor = Gray
End Sub
Now the "rest of the story": This procedure may get called depending on
the user clicking correctly on "Yes" or "No" in either a UserForm or a
Msgbox. (I've tried both userform and msgbox--and both create the
problem.) IF I leave the Userform or Msgbox where it first appears on
the screen, then everything works fine, BUT if I move either the Msgbox
or UserForm, the "no-red" problem happens. (I'm moving it because I'd
like to have the Userform or Msgbox appear at a specific location over
the spreadsheet.)
Any suggestions why this is happening and how to fix it?
Thanks.
Bert





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
change the face color of an Excel command button Chris Leah Excel Discussion (Misc queries) 5 April 21st 23 09:03 AM
Change color of command button dhstein Excel Discussion (Misc queries) 1 May 21st 09 01:08 AM
Excel Command Button Color justbrewit Excel Programming 5 August 15th 06 11:22 PM
Command Button Color For Next Loop John Wilson Excel Programming 3 September 15th 05 05:57 PM
command button color mark kubicki Excel Programming 1 August 13th 04 05:29 PM


All times are GMT +1. The time now is 04:22 AM.

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"