Hi,
I’m quite new to InDesign scripting :)
I am trying to create a script to go through each page in a document, check which stylesheet is applied to the first paragraph on the page, and maybe make changes to it if it’s a certain stylesheet.
I am stuck on selecting the first paragraph on the page.
Here are the bare bones of my script:
function Main() {
var myDocument = app.activeDocument;
var myParStMainHeading = myDocument.paragraphStyles.itemByName(“main heading”);
var myCharStMainHeadingTop = myDocument.characterStyles.itemByName(“hidden”);
var myPageCount = myDocument.pages.length;
for(var i =0;i<=myPageCount;i++){
myPage=myDocument.pages.item(i);
// Here I need to get the first paragraph on the page into the var “myFoundItem”
if (myFoundItem == myParStMainHeading) {
myFoundItem.applyCharacterStyle(myCharStMainHeadingTop, true);
}
}
}
This is the bit I need help with:
// Here I need to get the first paragraph on the page into the var “myFoundItem”
What’s the best way to do this?
Thanks!
Pat Bensky