Find ParagraphStyle and Content Script
Hello,
I have a document with 4 pages. On page 1,2, and 4 there is a text that has a ParagraphStyle, on page 3 there is text without this phStyle.
Through a script I now want to find the pages and the content of the text.
var allPages = app.activeDocument.pages;
for (var i = 0; i < allPages.length; i++) {
var page = allPages[i];
var ftDm = page.textFrames[0];
var result = app.documents.firstItem().findText();
var curPhContents = result[i];
if (page.textFrames.length > 0) {
if (
ftDm.paragraphs[0].appliedParagraphStyle.name == "Name" &&
curPhContents != undefined
) {
output = curPhContents.contents.replace(/\r/g, "").replace(/\s+$/g, "");
$.writeln(
"Found on page " +
page.name +
": Text with the paragraphStyle: " +
output
);
} else {
$.writeln("No paragraphStyle found");
}
}
}
Page 1 and 2 it finds, on page 3 it says error, but it does not continue on page 4.

Am a little confused.
