【问题标题】:Can't get Applescript to change Paragraph style of text frame in InDesign无法让 Applescript 在 InDesign 中更改文本框架的段落样式
【发布时间】:2017-07-10 13:55:47
【问题描述】:

我正在尝试编写一个“简单”的小程序,它将在 InDesign 中找到一个具有特定属性的文本框架,然后更改该特定文本框架的段落样式。我知道 if 语句是正确的,因为我将它用于其他 applescript。 所以我有一个名为“PriceBox”的对象样式的文本框架。如果文本框架中包含斜杠“/”,我想将段落样式更改为“2for”。我确认文档中存在段落样式。但是,当我运行脚本时,我得到了这个错误:

错误“无法将 {«class txtf» id 6905 of «class sprd» id 6891 of document id 4 of application \"Adobe InDesign CC 2015\"} 设置为 \"2for\" 的 «class psty»。 "编号 -10006 从 {«class txtf» 的 «class psty» id 6905 of «class sprd» id 6891 of document id 4} 到 «class 2for»

我尝试了“设置段落样式”脚本的变体,但它们似乎都不起作用。请帮忙! =) 谢谢!

告诉应用程序“Adobe InDesign CC 2015”

tell active document
    set horizontal measurement units of view preferences to inches
    set vertical measurement units of view preferences to inches
    repeat with x from 1 to count pages
        set ThisPage to page x
        tell ThisPage
            if exists (text frames whose (name of applied object style is "PriceBox" and contents contains "/$")) then
                set paragraph style of (get text frames whose name of applied object style is "PriceBox") to "2for"
    end if  
        end tell
    end repeat
end tell

说完

【问题讨论】:

    标签: applescript adobe stylesheet adobe-indesign


    【解决方案1】:

    您正在测试“/$”而不仅仅是“/”。

    您不能将段落样式直接应用于文本框架。您将需要使用段落。

    还需要遍历帧

    tell application "Adobe InDesign CC 2015"
        tell active document
            set horizontal measurement units of view preferences to inches
            set vertical measurement units of view preferences to inches
            repeat with x from 1 to count pages
                set ThisPage to page x
                tell ThisPage
                    if exists (text frames whose (name of applied object style is "PriceBox" and contents contains "/$")) then
    
                        set myFrames to (text frames whose (name of applied object style is "PriceBox" and contents contains "/$")))
                        tell myFrames
                            repeat with r from 1 to count items
                                set applied paragraph style of paragraphs of item r of myFrames to "2For"
                            end repeat
                        end tell
                    end if
                end tell
            end repeat
        end tell
    end tell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      相关资源
      最近更新 更多