使用AppleScript在Numbers中设置边框?

时间:2014-09-04 15:19:15

标签: applescript

我已成功设法让AppleScript通过引用background color属性来操作Numbers文档中的背景颜色。但是,我也想设置一个选区或一系列单元格的边框。

我已经在AppleScript编辑器的“字典”中查找了可以帮助我的命令或属性,但我还没找到任何东西。是否无法使用AppleScript在Numbers中创建边框?

2 个答案:

答案 0 :(得分:1)

AppleScript字典中没有任何内容允许此功能(这很糟糕,IMO,但如果有足够的人抱怨,Apple可能会在将来添加此功能)。

答案 1 :(得分:0)

可以使用 SystemEvents 与 Numbers 的界面交互添加边框:

-- Set the selection range
tell application "Numbers"
    make new document
    tell front document to tell active sheet to tell table 1
        set selection range to range "A3:C6"
    end tell
end tell

-- Asks System Events to interact with the interface
tell application "System Events" to tell application process "Numbers"
    -- Asks the main window to click on the button called 'Cell' (the name depends of your system language)
    tell window 1
        click radio button "Cell" of radio group 1

        -- Scroll area 4 is the inspector area
        tell scroll area 4
            -- The first incrementor of the inspector is the borders' one.
            increment incrementor 1
        end tell
    end tell
end tell

如果您想操作界面的其他元素,我建议使用 Xcode 附带的 Accessibility Inspector 应用程序。