Just a short post to add another AppleScript snippet some might find useful. (There will be performance-related posts along shortly; I have some in the works.)
As you know from previous posts under the tag topics, I’m automating as much of my Excel use as possible.
So here’s a short snippet of AppleScript to set the x (category) axis font size. It then sets the primary (left) y axis font size to the same. Finally, if there is a secondary (right) y axis it sets its font size.
Generally I find 14 point to be the right size. Obviously you could generalise this with a variable or use another hardcoded size.
The way I use this is to run the AppleScript fragment having selected the chart I want to apply it to.
I think the code is pretty self explanatory:
tell application "Microsoft Excel"
set c to active chart
tell c
set a to (get axis axis type category axis)
set font size of (font object of tick labels of a) to 14
set b to (get axis axis type value axis which axis primary axis)
set font size of (font object of tick labels of b) to 14
if get has axis axis type value axis axis group secondary axis then
set c2 to (get axis axis type value axis which axis secondary axis)
set font size of (font object of tick labels of c2) to 14
end if
end tell
end tell
As I’ve said several times, there aren’t many examples of AppleScript driving Excel. My hope is some of my posts get indexed on the wider web and so add to what searches throw up.
One thought on “Setting Axis Font Sizes In Excel With AppleScript”