Wednesday, December 8, 2021

#1 2021-11-17 02:51:40 pm

Skillet
Member
Registered: 2010-01-11
Posts: 136

Microsoft Excel - Tell Active Window No Longer Working

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.

Applescript:

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


macOS 10.13.4

Offline

 

#2 2021-11-18 11:18:32 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2182

Re: Microsoft Excel - Tell Active Window No Longer Working

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:

Applescript:


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

Last edited by KniazidisR (2021-11-18 11:30:26 pm)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2021-12-06 11:53:50 am

Skillet
Member
Registered: 2010-01-11
Posts: 136

Re: Microsoft Excel - Tell Active Window No Longer Working

Thank you very much that worked!


macOS 10.13.4

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)