Article View: adobe.scripting.indesign
Article #10107Re: Script to select certain styles
From: Dave_Saunders
Date: Wed, 05 Jul 2006 15:41
Date: Wed, 05 Jul 2006 15:41
21 lines
1639 bytes
1639 bytes
OK, you're confusing how the UI works with how scripts work. You don't need to "select the text" but rather reference each instance.
A scripted Find will do the job. Something like this:
if (app.documents.length == 0) { exit() }
aDoc = app.activeDocument;
myStyle = aDoc.paragraphStyles.item("BodyText"); // Use your style name
app.findPreferences = null;
app.changePreferences = null;
app.findPreferences.appliedParagraphStyle = myStyle;
myFinds = aDoc.search("",false,false,undefined);
for (j = 0; myFinds.length > j; j++) {
myFinds[j].appliedParagraphStyle = myStyle;
}
It's interesting that if you just do a Find/Change with myStyle set as the app.changePreferences.appliedParagraphStyle, nothing happens, but applying the style to each found instance, as I've done here, will eliminate local styling while preserving character styling.
Not clear if that is actually what you wanted to do.
Dave
Technical Details
Message-ID:
<3bc0d10c.4@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc0d10c.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,fe777e15d8f79e88 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: Script to select certain styles Message-ID: <3bc0d10c.4@webcrossing.la2eafNXanI> Date: Wed, 5 Jul 2006 08:41:11 -0700 References: <3bc0d10c.-1@webcrossing.la2eafNXanI> Lines: 25 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing