Article View: adobe.scripting.indesign
Article #19518Re: Apply character style to certain characters in certain paragraphs?
From: Olav Kvern
Date: Sat, 14 Dec 2002 19:37
Date: Sat, 14 Dec 2002 19:37
57 lines
3362 bytes
3362 bytes
Kari--
Filter clauses make my head hurt. The problem with the first example is that you're not talking to a text object reference--ParaStyle is a reference to a paragraph style and has no characters. Anyway, why not use InDesign's search method to do what you want to do? Something like this:
tell application "InDesign 2.0.1"
--Create an example document.
set find preferences to nothing
set change preferences to nothing
set myDocument to make document
tell myDocument
set myParaStyle to make paragraph style with properties {name:"ki"}
set myCharStyle to make character style with properties {name:"Kirjallisuus nimet"}
set myPage to page 1
set myBounds to my myGetPageBounds(myPage, myDocument)
set myString to "Something Unusual: Just another day at Ohtori Academy." & return
set myString to myString & "Gracefully Cruel: Is he her prince, or what?" & return
set myString to myString & "What is Destiny?: Grrr. That Touga!" & return
set myString to myString & "For Friendship, Perhaps: Wakaba to the rescue!" & return
set myString to myString & "Time for us to go Back: What a weird day it's been!" & return
set myTextFrame to make text frame with properties {geometric bounds:myBounds, contents:myString}
set applied paragraph style of parent story of myTextFrame to myParaStyle
--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
on myGetPageBounds(myPage, myDocument)
tell application "InDesign 2.0.1"
set myMarginPreferences to margin preferences of myPage
set myDocumentPreferences to document preferences of myDocument
tell myPage
set myX1 to margin left of myMarginPreferences
set myY1 to margin top of myMarginPreferences
set myX2 to (page width of myDocumentPreferences) - (margin right of myMarginPreferences)
set myY2 to (page height of myDocumentPreferences) - (margin bottom of myMarginPreferences)
end tell
end tell
return {myY1, myX1, myY2, myX2}
end myGetPageBounds
Does that work for you?
Thanks,
Ole
Technical Details
Message-ID:
<1de70177.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!fr.clara.net!heighliner.fr.clara.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-7-bit X-Google-Thread: f939a,9795ba63ba0468bb X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-14 11:37:31 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!fr.clara.net!heighliner.fr.clara.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.0@WebX.la2eafNXanI> Date: Sat, 14 Dec 2002 11:37:14 -0800 References: <1de70177.-1@WebX.la2eafNXanI> Lines: 68 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit