Article View: adobe.scripting.indesign
Article #19519Re: Apply character style to certain characters in certain paragraphs?
From: Kari Puikkonen
Date: Sun, 15 Dec 2002 12:29
Date: Sun, 15 Dec 2002 12:29
55 lines
2412 bytes
2412 bytes
Ole,
Thanks for your advise! I fixed the script to my purpose:
tell application "InDesign 2.0.2"
set find preferences to nothing
set change preferences to nothing
tell document 1
set myParaStyle to paragraph style "ki"
set myCharStyle to character style "Kirjallisuus nimet"
--User find/change to apply the character style.
set myFoundItems to search for ":" with find attributes {paragraph style:myParaStyle}
repeat with myFoundItem in myFoundItems
set myStart to index of character 1 of paragraph 1 of myFoundItem
set myEnd to index of myFoundItem
tell parent story of myFoundItem
set applied character style of characters myStart through myEnd to myCharStyle
end tell
end repeat
end tell
end tell
�and it works, but for reason unknown to me it�s veeryy sloow. I wonder why?
But I also managed to compile script that uses those head spinning whose clauses�
tell application "InDesign 2.0.2"
tell active document
set findStyle to paragraph style "ki"
set charStyle to character style "Kirjallisuus nimet"
repeat with i from 1 to count stories
tell story i
repeat with j from (count (paragraphs whose applied paragraph style is findStyle)) to 1 by -1
tell (item j of paragraphs whose applied paragraph style is findStyle)
set applied character style of text from character 1 to (character 1 whose contents = ":") to charStyle
-- and whatever else you want
end tell
end repeat
end tell
end repeat
end tell
end tell
� and it is very fast!! I wonder why?
Kari the Ever Confused
Technical Details
Message-ID:
<1de70177.1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de70177.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,9795ba63ba0468bb X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-15 04:37:48 PST From: "Kari Puikkonen" <kari.puikkonen@welho.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Apply character style to certain characters in certain paragraphs? Message-ID: <1de70177.1@WebX.la2eafNXanI> Date: Sun, 15 Dec 2002 04:29:17 -0800 References: <1de70177.-1@WebX.la2eafNXanI> Lines: 54 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit