Article View: adobe.scripting.indesign
Article #16091Re: "Bolding" all words before hyphen in classifieds...advice please?
From: Dave_Saunders
Date: Wed, 15 Oct 2003 11:22
Date: Wed, 15 Oct 2003 11:22
28 lines
2188 bytes
2188 bytes
Here you go. Just change the property to have the names of the paragraph styles on which you want the script to operate, and make sure there's a character style named Bold.
If you run it with a text selected, it will operate on the story that contains the text. If you run it with nothing selected, it will operate on the whole document:
property runinParaStyles : {"First", "Second"}
tell application "InDesign 2.0.2"
try
set myRange to object reference of parent story of selection
on error
set myRange to document 1
end try
set find preferences to nothing
set change preferences to nothing
repeat with myStyle in runinParaStyles
set myParaStyle to (paragraph style 1 of document 1 whose name is myStyle)
set myEms to search myRange for "^_" with find attributes {applied paragraph style:myParaStyle}
repeat with myEm in myEms
set myStory to object reference of parent story of myEm
set myEnd to (index of character 1 of myEm) - 1
set myStart to index of paragraph 1 of myEm
set applied character style of characters myStart through myEnd of myStory to character style "Bold" of document 1
end repeat
end repeat
end tell
Like I said, this script will be obsolete with the release of ID CS, which will allow you to call for the run-in in those paragrah styles using a nested style.
Dave
Technical Details
Message-ID:
<2ccddd2c.3@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccddd2c.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,b3734101a930c616 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-10-15 04:38:13 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: "Bolding" all words before hyphen in classifieds...advice please? Message-ID: <2ccddd2c.3@webx.la2eafNXanI> Date: Wed, 15 Oct 2003 04:22:22 -0700 References: <2ccddd2c.-1@webx.la2eafNXanI> Lines: 37 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit