This content has been marked as final. Show 7 replies
The trouble is, theDoc doesn't have paragraphs. If you open the InDesign dictionary and look at the document object, you'll see text frames, and you'll see stories, but no paragraphs. To get all of the paragraphs, you'd use something like this:
set theText to every paragraph of every story
But getting every paragraph of every story whose applied paragraph style is a specific style is harder to do using a filter ("whose") clause, because it has multiple conditions. Shane can probably do it, but I'm not having much luck. All the same, why bother? InDesign has a perfectly good find text method that will do what you want. Something like this:
tell application "Adobe InDesign CS3"
--Clear the find text preferences
set find text preferences to nothing
set applied paragraph style of find text preferences to paragraph style "Greeting" of document 1
tell document 1
set myFoundItems to find text
Truly, thou art a juggernaut of scripting knowledge! That did exactly what I wanted. I just tweaked it a bit so that myFoundItems would return as a string and it gave me the text I wanted.
I knew I was not doing something right. I didn't realize that InDesign's find text feature would do what I wanted. This forum has been so helpful! Thanks!!
As Ole says, using find is usually a more sensible approach for this. But<br />for the record, this should work:<br /><br />tell document 1<br />set theStyle to paragraph style "Greetings"<br />set theText to every paragraph of every story whose applied paragraph style<br />is theStyle <br /><br /><br />-- <br />Shane Stanley <firstname.lastname@example.org>
I tried that, actually, and doesn't work for me.
On 14/8/08 8:33 AM, "Olav Kvern" <email@example.com> wrote:<br /><br />> I tried that, actually, and doesn't work for me.<br /><br />Odd. I just tested it here and it works fine for me. Did you use a reference<br />to the style or just its name? That makes a difference.<br /><br />-- <br />Shane Stanley <firstname.lastname@example.org>
I have another question. How would the syntax change if I was doing this in CS instead of CS3? I used what Ole wrote and I changed the syntax for CS, but I keep getting the error "InDesign CS got an error: Can't get find text of document 1." The words "find text" are then highlighted in the script.
Any ideas? Thanks!
Hi I am also looking for the same type of example. i am using IDCS3, windows and VB. i have some text with specified character format. i need to get the text with specified character format. please help to write a script to get the text. if you could help me for this it will e great. thanks.