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

问题描述 投票:1回答:1

在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”但是没有用。有没有更简单的方法来删除工作表中的所有边框?

excel applescript border applescript-excel
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.