我正在尝试编写一个“简单”的AppleScript,它会在InDesign中找到具有特定属性的文本框架,然后更改该特定文本框架的Paragraph样式。我知道if语句是正确的,因为我将它用于其他的应用程序。 所以我有一个文本框架,其对象样式称为“PriceBox”。如果文本框中包含斜杠“/”,我想将段落样式更改为“2for”。我确认文档中存在段落样式。但是,当我运行脚本时,我收到此错误:
错误“无法将应用程序文档ID 4的«class sprd»id 6891的{«class txtf»id 6905设置为«class psty»到”2 for for“。 “数字-10006来自«class psty»的{«class txtf»id 6905 of«class sprd»id 6891 of document id 4} to«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
告诉
答案 0 :(得分:0)
您正在测试“/ $”而不只是“/”。
您无法直接将段落样式应用于文本框架。您需要使用段落。
还需要遍历框架
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