Applescript + InDesign 在 Table 中选择正文行

Applescript + InDesign Selecting Body Rows In Table

我目前正在尝试自动执行某些数据格式设置。源数据的格式为 Excel。 inDesign 模板已经格式化。我可以右键单击 table 和 select 正文行,然后粘贴数据,看起来很漂亮。我想删除此步骤,但无法弄清楚如何将 applescript 获取到 inDesign 模板的 select table 和正文行。 以下两个似乎都不起作用。

set selection to body rows of table 1 of active document 
select body rows of table 1 of active document

如果对此有任何帮助,那就太好了。

我认为您需要以不同的方式引用您的 table。试试这个:

 set allTables to every table of every story of active document

 set myTable to item 1 of allTables

那么你应该能够 select 行:

tell table myTable

select first row

end tell

不幸的是,select 命令仅适用于单行,而不适用于 selected table.

中的所有行

基本上,您必须逐行决定row type。一旦您确定该行是 body row,您就可以 select 它。

将 selected 行添加到另一个 selected 行的语法非常棘手,尤其是在没有示例的情况下。请参阅下面的完整脚本。

    tell application "Adobe InDesign CC 2015"

    set allBodyRows to every row of every table of every story of active document whose row type is body row

    set bodyRow to {}
    repeat with i from 1 to (count allBodyRows)
        set bodyRow to item i of allBodyRows
        if i = 1 then
            select bodyRow
        else
            select bodyRow existing selection add to
        end if
    end repeat

    end tell
--author by RyuAutodidacte
tell application "Adobe InDesign 2020"
tell active document
    --When the selection is a text frame
    set FirstBodyCell to index of first cell of table 1 of selection whose row type is body row
    set LastBodyCell to index of last cell of table 1 of selection whose row type is body row
    select cells FirstBodyCell thru LastBodyCell of table 1 of selection
end tell
end tell