Tuesday, May 23, 2017

#1 2017-01-04 03:29:44 pm

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

Format Range of Cells in Excel without Strikethrough

Okay I am stumped on this one and after trying for well over an hour my google skills are failing me.  I am trying to make a range of cells no longer have strikethrough formatting.  I can set other cell formating values like bold but strikethrough is what I need to fix.

Doesn't work

Applescript:

tell application "Microsoft Excel"
   
   tell active sheet
       
       set range1 to range "B3:B11"
       
       set font style of font object of range1 to "Bold"
       --set font style of font object of range1 to set strikethrough to false
       
       get font style
       set strikethrough to false
       
   end tell
   
end tell

Strikethrough dosn't work

Applescript:

--http://forum.keyboardmaestro.com/t/ms-excel-apply-formatting/1552/3

tell application "Microsoft Excel"
   
   tell worksheet "Daily Priorities" of active workbook
       set range1 to range "B3:B11"
       
       tell range1
           
           set bold to false
           set font size to 12
           get font style
           set strikethrough to false
           
           --get underline
           --set font style to "underline"
           set font style to "Bold"
           
           --get color
           set color to {255, 0, 0}
           set name to "Times New Roman"
           
           (*
                   set {name, font style, font size, strikethrough, superscript, subscript, ¬
                       outline font, shadow, font color index} to {"Arial Narrow", "Italic", ¬
                       10, false, false, false, false, false, color index automatic}
               *)

       end tell
   end tell
   
   
end tell

Offline

 

#2 2017-01-04 04:51:04 pm

haolesurferdude
Member
Registered: 2010-02-19
Posts: 82

Re: Format Range of Cells in Excel without Strikethrough

In your first script simply change your set strikethrough to the following:

Applescript:

set strikethrough of font object of range1 to false

Offline

 

#3 2017-01-04 05:12:40 pm

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

Re: Format Range of Cells in Excel without Strikethrough

You are awesome, that works like a charm, thanks a bunch!

Applescript:

tell application "Microsoft Excel"
   
   --tell active sheet
   tell worksheet "Daily Priorities" of active workbook
       
       set range1 to range "B3:B11"
       
       set font style of font object of range1 to "Bold"
       set bold of font object of range1 to false
       
       --set font style of font object of range1 to "Strikethrough" --Oddly the same logic doesn't apply to strikethrough, instead do
       set strikethrough of font object of range1 to true
       set strikethrough of font object of range1 to false
               
   end tell
   
end tell

For what it's worth that helped me figure how to do it in the style of the first AppleScript for anyone searching for this in the future (it just might end up being me again).

Applescript:

--http://forum.keyboardmaestro.com/t/ms-excel-apply-formatting/1552/3

tell application "Microsoft Excel"
   
   --tell active sheet
   tell worksheet "Daily Priorities" of active workbook
       
       set range1 to range "B3:B11"
       tell range1
           set value to "New Words In This Cell"
           set cellStyle to font object
           
           tell cellStyle
               
               set bold to false
               set font size to 12
               --get font style
               set strikethrough to true
               
               --get underline
               --set font style to "underline"
               set font style to "Bold"
               
               --get color
               set color to {255, 0, 0}
               set name to "Times New Roman"
               
               (*
               set {name, font style, font size, strikethrough, superscript, subscript, ¬
                   outline font, shadow, font color index} to {"Arial Narrow", "Italic", ¬
                   10, false, false, false, false, false, color index automatic}
           *)

           end tell
       end tell -- cellStyle
   end tell -- range1
   
end tell

Last edited by Skillet (2017-01-04 05:44:58 pm)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.079 seconds, 9 queries executed ]

RSS (new topics) RSS (active topics)