Skip to main content
Inspiring
November 2, 2011
Answered

Selecting Next Page Items

  • November 2, 2011
  • 1 reply
  • 769 views

I'm having some trouble selecting the text frame on the next page for some reason. I looked at some previous discussions and there didn't seem to be a solution mentioned. Is there a better way to do this? Thanks!

doc = app.activeDocument;



for (i=0; i<doc.pages.length; i++) {

          currentPage = doc.pages.item(i);

          nextPage = doc.pages.item(currentPage.documentOffset+1);


          if (nextPage.textFrames.item(0).paragraphs > 2) {

                    currentPage.textFrames.item(0).textFramePreferences.verticalJustification = 1785951334;

          }



}


This topic has been closed for replies.
Correct answer Josh000000

Never mind! Just figured it out for anyone interested... turns out it was something small. It kept giving an error because when it would get to the end of the document it would look for the "next page" and it wouldn't find one. Subtracting 1 from the length of the document seems to fix it.

Wonder how many times people mark there own answer as the correct one...

doc = app.activeDocument;



for (i=0; i<doc.pages.length-1; i++) {

          currentPage = doc.pages.item(i);

          nextPage = doc.pages.item(i+1);


          if (nextPage.textFrames.item(0).paragraphs.length > 2) {

               alert("Stuff");

          }



}

1 reply

Inspiring
November 2, 2011

Also, now that I'm thinking about it, is there any way to select the last line of text before a page break (not a page break character but a page break built into the paragraph style on the next page (in the keep options, "on next odd page"))...

I'm trying to write a script that will vertically justify every page except for the end of chapters which will be top aligned (and some other exceptions too, but that's the general gist of it).

Josh000000AuthorCorrect answer
Inspiring
November 2, 2011

Never mind! Just figured it out for anyone interested... turns out it was something small. It kept giving an error because when it would get to the end of the document it would look for the "next page" and it wouldn't find one. Subtracting 1 from the length of the document seems to fix it.

Wonder how many times people mark there own answer as the correct one...

doc = app.activeDocument;



for (i=0; i<doc.pages.length-1; i++) {

          currentPage = doc.pages.item(i);

          nextPage = doc.pages.item(i+1);


          if (nextPage.textFrames.item(0).paragraphs.length > 2) {

               alert("Stuff");

          }



}

John Hawkinson
Inspiring
November 2, 2011

Wonder how many times people mark there own answer as the correct one...

Historically, very few, because the forum software did not allow that prior to the upgrade a month ago.