Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change the face color of an Excel command button | Excel Discussion (Misc queries) | |||
Change color of command button | Excel Discussion (Misc queries) | |||
Excel Command Button Color | Excel Programming | |||
Command Button Color For Next Loop | Excel Programming | |||
command button color | Excel Programming |