如何删除工作表中的所有边框?

时间:2017-12-20 00:42:04

标签: excel applescript border applescript-excel

在AppleScript和Excel中,我可以使用以下内容从单元格中删除边框:

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

Remove cell borders学习,但我在尝试从工作表中删除所有边框时遇到问题,而无需逐步浏览每个列和行。我已经想出如何获得活动表:

set activeSheet to worksheet (get name of active sheet) of workbook (get name of active workbook)

在研究文档时我看到了:

autoshape line callout one no border
autoshape line callout two no border
autoshape line callout three no border
autoshape line callout four no border

但我似乎无法弄清楚如何在不插入每个列和行的情况下删除所有边框。从我的搜索中我发现了“How do I use AppleScript to clear a range of cells in excel 2008”,但这不起作用。有没有更简单的方法来删除工作表中的所有边框?

1 个答案:

答案 0 :(得分:2)

您可以访问活动工作表的已用范围,以删除该范围内的所有边框。

 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