Flash Text Color in Shape

bubastisbastet

New Member
Joined
Oct 11, 2008
Messages
11
Hi All,

I am trying to write VB to enable the text on a macro button to briefly flash red when the button is pressed, and then return to the default white color thereafter (as a means for a user to get an indication that pressing the button actually 'did something').

My code is as follows:

Code:
Sub test()
Dim x As Single
x = Timer

With ActiveSheet

.Shapes("AutoShape 109").TextFrame.Characters.Font.ColorIndex = 3

While Timer - x < 0.5
Wend

.Shapes("AutoShape 109").TextFrame.Characters.Font.ColorIndex = 2

End With

End Sub
oddly, this code only reverts to the second defined color (colorindex = 2), but will not cycle between the two.

however, the following code, when applied to text within a cell (A1 in this instance), DOES work:

Code:
Sub test2()

Dim x As Single
x = Timer

With ActiveSheet
.Range("a1").Font.ColorIndex = 3


While Timer - x < 0.5
Wend


.Range("a1").Font.ColorIndex = 2
End With
    
End Sub
Any suggestions as to why it won't work when applied to text within a shape?

Many thanks!!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,224,592
Messages
6,179,787
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top