4 Replies Latest reply on Jun 1, 2014 2:54 AM by virender_CTS

    How to know which text frame's page number in cs6?

    virender_CTS Level 1

      Hello all,

      I want to know page number of selected textframe. I tried different properties but unable.

      Help need on this line:      alert(i + " " + myFrame.id + "   " + myFrame.parentPage.id);  // here i want page number to be displayed

       

      #target Indesign

      var myDoc = app.documents.item(0);

      var i;

          for(i=0; i < myDoc.textFrames.length; i++)

      {

              var myFrame = myDoc.textFrames[i];

          myFrame.select(); 

           alert(i + " " + myFrame.id + "   " + myFrame.parentPage.id);  // here i want page number to be displayed

      }

       

      thanks

      virender

        • 1. Re: How to know which text frame's page number in cs6?
          pixxxel schubser Level 5

          Hi virender_CTS;

           

          try:

          myFrame.parentPage.name
          

           

          Have fun.

           

          • 2. Re: How to know which text frame's page number in cs6?
            AS Scripter Level 1

            In Applescript:

             

            tell application "Adobe InDesign CS6"

              return name of parent page of selection -->  "7"

            end tell

            • 3. Re: How to know which text frame's page number in cs6?
              Laubender Adobe Community Professional & MVP

              @Virender –if you need a Number, not a String – name is a string object – you could use the value of documentOffset for the parentPage. It starts with the number 0 on page 1 of a document. Regardless of the name. A name for page 1 could well be "0020" or "20" or "XX". Or "1".

              And a name is not unique. If more than one section is present a name like "1" could there more than one time.

               

              myFrame.parentPage.documentOffset;
              

               

              However, parentPage could be null, if the object is sitting on the pasteboard.
              And as you are looping through all textFrames of a document, this could well be.

               

              Instead loop through all pages of the document. And from that through all textFrames.

              Then you can be sure, that all textFrames you are visiting have a valid parentPage property.

               

              Or do it like that:

               

              if(myFrame.parentPage != null){
              $.writeln(myFrame.parentPage.documentOffset +"\t"+ myFrame.parentPage.name +"\t"+ myFrame.id)
              }
              

               

              Oh, just another question:

               

              Why would you like to select myFrame with: myFrame.select() ?

              What would you hope to accomplish by doing that?

               

              Uwe

              • 4. Re: How to know which text frame's page number in cs6?
                virender_CTS Level 1

                Hi Uwe,

                 

                thanks for your help on the document offset.

                For your question about myFrame.select() is. In a monthly publication where page heading and numbers remains same but the content changes.

                Few month ago, i created a script to import text on selected text frames and for that i need their frame Id or frame label.

                I found frame id is the best option as per my best knowledge on scripting. so i used above mentioned script to know the required frame ID and then assign respective rtf file for import on specific frame ID.

                 

                thanks again

                Virender