It's been a while since I've applescripted and it's showing.
I have a rigidly formatted text document placed into Indesign CS(1) and
need to find specific words and apply different paragraph styles to them.
That's the short story.
Here's an example of the placed text:
*CODE* ZZ111
*ADDRESS*
*HEADING* ABSOLUTELY MAGNIFICENT
*BULLET 1* Some text
*BULLET 2* Some more text
*BULLET 3* Even more text
I am using Adobe's sample script "TextCleanup.as" as my starting point. If
you haven't used it, it reads in a delimited set of parameters from a text
file and performs a FIND/CHANGE function using that list.
I've created a text file that enables the script to remove all the words
between the asterisks by replacing each one with nothing or with a bullet
and tab as required.
What I also need it to do is to apply a paragraph style according to the
word it's replacing. So *ADDRESS* would have AddressStyle applied to that
line (para) before *ADDRESS* is deleted.
The line that does the grunt work in the sample script is:
set myFoundItems to (search for myFindString replacing with myChangeString
without whole word and case sensitive)
This obviously performs the find/change and is within a repeat loop so it
replaces all matches.
What I need to do is to tell it to not only change the text string but the
formatting too. The Indesign Scripting Guide says it can do it but it
gives no hint as to how.
I've added a parameter to each line in the text file for "myStyle" and
edited the script to read this in too. I just don't know how to apply it
to each Find result.
Examples I've found online tend to reference things in a specific order
(Para1, Para2, ...) and are too restrictive given the varierty of
documents I'm dealing with.
That's the long story.
Thanks in advance,
--
Andy D