VBA in MacOS to change color of the font in a Shape

BritsBlitz

New Member
Joined
Jan 10, 2014
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I have a VBA code to change the font color of a button when you click on it (Form Control, not Active X). If the current font color is Black, it will change to Orange once you click on the button. (FC is defined as Shape and is the Forms Control button I'm clicking on). On a PC, the code works fine. On a MAC, I get an error.

For PC, I used:
If FC.TextFrame.Characters.Font.Color = RGB(0, 0, 0) Then
FC.TextFrame.Characters.Font.Color = RGB(255, 102, 0)


When I run the same code on a MAC, I get an error and it seems like MAC doesn't like the .TextFrame.Characters. reference.
The error on a MAC is: "Run-time error '1004': Method 'TextFrame" of object 'Shape' failed

I tried recording the macro to see how MAC handles it, but it's different because you have to first select the button, then change the font color. The recorded macro is the same on PC and MAC which isn't helpful:
With Selection.Font
.Size = 12
.Underline = xUnderlineStyleNone

.Color = 15773696
End With

Any feedback if there is an alternative to .TextFrame.Characters.Font.Color = RGB(x.x.x) on a MAC?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I am assuming you are talking about a button in sheet not in a userform.

What you could do is on the Apple in the VB editor, open the Object Browser (View menu). Find Shape in the list and see what properties and methods it has. On PC it has the TextFrame as one of its properties.
 
Upvote 0
I am assuming you are talking about a button in sheet not in a userform.

What you could do is on the Apple in the VB editor, open the Object Browser (View menu). Find Shape in the list and see what properties and methods it has. On PC it has the TextFrame as one of its properties.
Hi Sijpie

Yes, I was referring to buttons. TextFrame is only supported on PC and I couldn't figure out what the alternative to TextFrame would be on a MAC. For the time being, I got around the issue by not using buttons at all and instead just placed a rectangle shape on the sheet and assigned the macro to the shape to change the shape color instead of the text color inside the button. I'm still looking for the MAC solution so will give your idea a try.
 
Upvote 0
With your rectangle shape you can also fill it with an image of a button, and have two identical images, one with black text, one with orange. Then n the macro swap the image of the shape.

Or what I often do is have both shapes on top of each other, and with the click of the shape change the visibility of each.

Good luck
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,128
Members
453,021
Latest member
Justyna P

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