[JS][CS3]Applying Character Style to First Word
I am a noob as far as Javascript is concerned, and I was hoping for a little guidance.
Here's my scenario: I have a book that has been typeset all in one file; the main content is all in one story. I want to select the first word of every text frame on each page and apply a character style. My goal is to utilize this character style to indicate page breaks in the XML--I'll map the style to a specific tag.
So far I have this poor specimen:
var myDocument = app.activeDocument;
var myPage = myDocument.pages.item(1);
var myTextFrame = myPage.textFrames.item(0);
if( app.activeDocument.stories[0].paragraphs[0].words[0] != null )
myTextFrame.paragraphs.item(0).words.item(0).appliedCharacterStyle =
myDocument.characterStyles.item('foo');
I know, I haven't set up any sort of loop yet (which will be trickier given the fact that there will be blank versos, etc). What I'm trying to do in this is to select the first word in the first paragraph on the second page--which it does in fact do. Problem is, the first paragraph on the second page starts on the first page, so I'm selecting that a word on the first page, not the second page.
As I said, lots of work to do but a little help on getting to the right word would be most appreciated.