Reputation: 8918
In AppleScript and Excel I can remove a border from a cell with something like:
tell application "Microsoft Excel"
set myRange to range "B2:B2" of active sheet
set myBorders to {border top, border bottom, border left, border right}
repeat with i from 1 to 4
set theBorder to get border myRange which border (item i of myBorders)
set line style of theBorder to line style none
end repeat
end tell
learned from Remove cell borders but I'm having issues trying to remove all borders from a worksheet without having to step through each column and row. I've figured out how to get the active sheet with:
set activeSheet to worksheet (get name of active sheet) of workbook (get name of active workbook)
and when researching the documentation I see:
autoshape line callout one no border
autoshape line callout two no border
autoshape line callout three no border
autoshape line callout four no border
but I can't seem to figure out how to remove all borders without stepping into each column and row. From my searches I found "How do I use AppleScript to clear a range of cells in excel 2008" but that didn't work. Is there any easier way to remove all borders in a worksheet?
Upvotes: 1
Views: 1787
Reputation: 1341
You could access the used range of the active sheet to remove all borders from that range.
tell application "Microsoft Excel"
set usedRange to used range of active sheet
set myBorders to {border top, border bottom, border left, border right}
repeat with i from 1 to 4
set theBorder to get border usedRange which border (item i of myBorders)
set line style of theBorder to line style none
end repeat
end tell
Upvotes: 2