I have been using MS Excel 2011 because it has been so much faster for my AppleScripts. However now on 16.29 because I have to be due to the OS this code is no longer working for some reason.
tell application "Microsoft Excel"
tell active window
set name of font object of selection to "Arial"
set color of font object of selection to {0, 128, 0} --Green
set font size of font object of selection to 12
set bold of font object of selection to false
set strikethrough of font object of selection to false
set underline of font object of selection to underline style none
set italic of font object of selection to false
end tell
end tell
I have Catalina and a different version of Excel. Therefore, you will have to test my proposal yourself. So, it’s often helpful to tell AppleScript explicitly to which object the object you want belongs to. This is done using the its keyword. Also, sometimes adding parentheses and the get keyword helps:
tell application "Microsoft Excel"
tell (get its active window) -- EDITED (full syntax)
tell (get its selection) -- ADDED (full syntax)
tell (get its font object) -- ADDED (full syntax)
set name to "Arial"
set color to {0, 128, 0} -- Green
set font size to 12
set bold to false
set strikethrough to false
set underline to underline style none
set italic to false
end tell
end tell
end tell
end tell