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

How can you remove all borders in a worksheet?

在 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 学习,但我在尝试从作品中删除所有边框时遇到问题sheet,而不必遍历每一列和每一行。我已经弄清楚如何通过以下方式获得活动 sheet:

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”,但这没有用。有没有更简单的方法去除作品中的所有边框sheet?

您可以访问活动的已使用范围sheet以删除该范围内的所有边框。

 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