Article View: adobe.scripting.indesign
Article #16093Re: "Bolding" all words before hyphen in classifieds...advice please?
From: Jay_Fraser
Date: Wed, 15 Oct 2003 15:49
Date: Wed, 15 Oct 2003 15:49
54 lines
2881 bytes
2881 bytes
Here's another option. It uses a "whose" clause -- which, IIRC, Dave dislikes [grin]:
tell application "InDesign 2.0.2"
if (count documents) > 0 then
set myDocument to active document
set myCharStyle to character style "Bold" of myDocument
set myHyphen to "-"
tell myDocument
try
set myPink to swatch "C=0 M=100 Y=0 K=0"
on error
set myPink to make color with properties {color model:process, color space:cmyk, color value:{0, 100, 0, 0}, name:"C=0 M=100 Y=0 K=0"}
end try
try
set myStory to object reference of parent story of selection
on error
activate
display dialog "Please select some text in the story you want to process."
end try
tell myStory
repeat with myCounter from 1 to (count paragraphs)
try
set myBoldThis to object reference of text from character 1 to (character 1 whose contents = myHyphen) of paragraph myCounter
set applied character style of myBoldThis to myCharStyle
on error
set fill color of text of paragraph myCounter to myPink
end try
end repeat
end tell
end tell
else
activate
display dialog "Please open a document and try again."
end if
end tell
This script assumes:
1) you have some text selected in the story you want to convert;
2) you have a character style named "Bold" (basically your regular style w/ bold applied, this is much slicker than simply applying bold.)
3) your hyphen is a regular hyphen. If you want to change that, change the character between the quotes in the 4th line to an en-dash or whatever. (in fact, you can even change it to a character like "c" & get some really cool effects. [grin] )
If the script has a problem with a paragraph, (for instance, if it can't find a hyphen) it changes the color of the text to magenta, then moves on. If this bugs you I can tell you how to disable it, but I find it helps with proofing.
HTH.
Technical Details
Message-ID:
<2ccddd2c.5@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news-xfer2.atl.newshosting.com!63.218.45.10.MISMATCH!newshosting.com!news-xfer1.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!newsfeed.arcor-online.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 09:08:07 PST From: Jay_Fraser@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news-xfer2.atl.newshosting.com!63.218.45.10.MISMATCH!newshosting.com!news-xfer1.atl.newshosting.com!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!newsfeed.arcor-online.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.5@webx.la2eafNXanI> Date: Wed, 15 Oct 2003 08:49:51 -0700 References: <2ccddd2c.-1@webx.la2eafNXanI> Lines: 61 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit