PC Review


Reply
Thread Tools Rate Thread

change color of command button problem

 
 
Bert
Guest
Posts: n/a
 
      24th Dec 2007
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.BackColor = Red
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Red
Application.Wait Now + TimeSerial(0, 0, 2)
Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Gray
Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.BackColor = 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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      24th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:fkoagf$elr$(E-Mail Removed)...
> 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.BackColor = Red
> Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Red
> Application.Wait Now + TimeSerial(0, 0, 2)
> Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Gray
> Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.BackColor = 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 With Quote
 
Bert
Guest
Posts: n/a
 
      24th Dec 2007
Bob:
That seemed to do the trick. Thanks

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%23Q3N8%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:fkoagf$elr$(E-Mail Removed)...
>> 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.BackColor = Red
>> Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Red
>> Application.Wait Now + TimeSerial(0, 0, 2)
>> Worksheets(2).OLEObjects.Item(BtnNo).Object.BackColor = Gray
>> Worksheets(2).OLEObjects.Item(FirstBtnNo).Object.BackColor = 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change color of command button dhstein Microsoft Excel Misc 2 21st May 2009 01:08 AM
Change color of command button dhstein Microsoft Excel Misc 0 21st May 2009 12:34 AM
Re: Why can't I change the color of a command button? fredg Microsoft Access Forms 0 19th Jan 2007 10:10 PM
Change color of a command button Tom Microsoft Access Form Coding 1 29th May 2006 01:21 AM
Change the color of the Command Button =?Utf-8?B?SmVmZg==?= Microsoft Access VBA Modules 2 7th Feb 2004 11:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 PM.