Macro to change font colour in Active Shape

ttratl

Board Regular
Joined
Dec 21, 2004
Messages
168
Hi Everyone,

I need to adapt this code so that it runs against a user selected shape (the "active shape").
Code:
Sub Macro2()
'
ActiveSheet.Shapes("Rounded Rectangle 1").TextFrame.Characters.Font.ColorIndex = 0

End Sub
At the moment, the shape name has to be used, and I can't use the names.

Any ideas?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Have you tried:
Code:
Selection.TextFrame.Characters.Font.ColorIndex = 0
?

or maybe just:
Code:
Selection.Font.ColorIndex = 0
 
Last edited:
Upvote 0
I believe Application.Caller can be used to obtain the name of the shape you're selecting.
 
Upvote 0
Thanks guys!

GlennUK - your second code seems to work fine (I can't believe I hadn't tried that in all the combinations I've been trying)

I've been concentrating on the .TextFrame element as I thought this HAD to be used.
Thankyou!

Moonfish - I couldn't get Application Caller to work in several combination of code I tried. I even tried a macro that did something completly different to what I wanted, to see if the AppCaller would work and it failed. Not sure why. Thanks for reply though!
 
Upvote 0
That's great!

I use Application.Caller if I've assigned macros to shapes ( right click, Assign Macro ) to see which shape has been clicked.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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