3 Replies Latest reply on Nov 1, 2011 11:08 PM by John Hawkinson

    Selecting Next Page Items

    Josh000000 Level 1

      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;

                }



      }


        • 1. Re: Selecting Next Page Items
          Josh000000 Level 1

          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).

          • 2. Re: Selecting Next Page Items
            Josh000000 Level 1

            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");

                      }



            }

            • 3. Re: Selecting Next Page Items
              John Hawkinson Level 5

              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.