For loop stops iterating at first page
I have a loop that applies a paragraph style but it stops iterating at the first page of the document.
I need it to apply the style to the entire document...can't figure out why this isn't working.
Here is my script:
var myDocument = app.activeDocument;
var myParagraphStyle = myDocument.paragraphStyles.item("Paragraph Style");
myDocument.pages.item(0).textFrames.item(0).paragraphs.item(0).appliedParagraphStyle = myParagraphStyle;
var paragraphs = myDocument.pages.item(0).textFrames.item(0).paragraphs
for( i = 0; i < paragraphs.length; i++)
{
var paragraph = paragraphs.item(i)
paragraph.applyParagraphStyle(myParagraphStyle, true);
}
Thank you