Article View: adobe.scripting.indesign
Article #18438Re: getting paragraph style (AS)
From: Dave Saunders
Date: Tue, 25 Mar 2003 15:01
Date: Tue, 25 Mar 2003 15:01
45 lines
2937 bytes
2937 bytes
There are so many issues here, I'm not sure how to start. The chances are that there's a much easier way to get at what you want by using a scripted search.
But let me try to help with your "paragraph style" problem.
Paragraph styles are properties of a document. They have names and they have lots of properties themselves.
But when it comes to an individual paragraph, from a scripting point of view, it doesn't have a paragraph style but rather an "Applied Paragraph Style."
Thus:
get applied paragraph style of paragraph 1 of selection
will return a reference to the paragraph style that is applied to the first paragraph that is part of the current text selection (or even the first paragraph of a text frame, if that's what you have selected).
But that will be in the form:
paragraph style id n of docment "Name"
Chances are that what you really need is:
get name of applied paragraph style of paragraph 1 of selection
Or, you can replace "paragraph 1 of selection" with any text reference. You can even get the names of the applied paragraph styles of every paragraph in a story:
get name of applied paragraph style of every paragraph of parent story of selection
or with a little less typing:
get name of applied paragraph style of paragraphs of parent story of selection
I hope this helps you understand paragraph styles.
But as to your actual issue, your script will run a whole lot faster if you use the search facility:
set find preferences to nothing
set myStyle to paragraph style "Title" of document 1
set myParas to search document 1 for "" with find attributes {applied paragraph style: myStyle}
This will result in "myParas" being a list of references to paragraphs of style "Title".
If you're planning to change the text of those paragraphs, process the list backwards so that your changes don't invalidate the other members of the list. Also, remember to avoid obliterating the return at the end of the paragraphs or you'll lose the style.
That's a lot of concepts in a small space. I hope it sets you in the right direction.
Dave
Technical Details
Message-ID:
<1de8712a.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de8712a.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,b4ddc4a8f97315c1 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-03-25 07:08:42 PST From: "Dave Saunders" <daves@pdsassoc.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: getting paragraph style (AS) Message-ID: <1de8712a.0@WebX.la2eafNXanI> Date: Tue, 25 Mar 2003 07:01:33 -0800 References: <1de8712a.-1@WebX.la2eafNXanI> Lines: 63 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit