4 Replies Latest reply on Sep 25, 2013 5:24 AM by Peter Kahrel

    Parent Page in CS4

    BEGINNER_X Level 3

      Hi All,

       

      I need to find page number wherever "XXX" is used in my active document (CS4).

       

      For CS5 and above, my tool is working fine using "ParentPage" property.

       

      But struggled in CS4 to find the page number with different kind of anchor, group etc.

       

      Works in few occurences and and may not in some other...

       

      Code is below:

       

      app.findTextPreferences = app.changeTextPreferences = null;
      app.findTextPreferences.findWhat = "XXX";
      
      var myFound = app.activeDocument.findText();
      alert("myFound: " + myFound.length)
      
      for(i=0; i<myFound.length; i++)
      {
           //if (myFound[i].parentTextFrames[0].parent.constructor.name== "Page" || myFound[i].parentTextFrames[0].parent.constructor.name== "Spread")
           //{
           alert(myFound[i].parentTextFrames[0].parent.name)
           //}
      }
      
      

      Please find the screenshot as shown as below:

       

      Picture 2.png

       

      Please please anyone help me to find out the solution.

       

      Thanks in advance

      Beginner_X

        • 2. Re: Parent Page in CS4
          Mac_rk

          try this   

           

          try{
               alert(myFound[i].parentTextFrames[0].parent.name)
               }
          catch(error){
               alert(myFound[i].parentTextFrames[0].parentPage.name)
               }

          • 3. Re: Parent Page in CS4
            BEGINNER_X Level 3

            Hi Peter/Mac/All,

             

            Thanks for your reply...

             

            I try the below code,

             

            I got to find the Anchor elements page number in CS4

             

            But am not able to find the Page number for group elements.

             

            Please tune or improve my below code:

             

             

            var myVersion = app.version.split(".")[0];
            myVersion = myVersion - 2
            var myVersionsuffix = app.version.split(".")[1];
            if (myVersionsuffix == 5) {
                var myVersion1 = "CS" + myVersion + "." + myVersionsuffix;
            } else if (myVersionsuffix == 0) {
                var myVersion1 = "CS" + myVersion;
            }
            
            
            app.findTextPreferences = app.changeTextPreferences = null;
            app.findTextPreferences.findWhat = "XXX"
             var myFound = app.activeDocument.findText();
               
            for(i=0; i<myFound.length; i++)
            {
              if ((myVersion1 == "CS5.5") || (myVersion1 == "CS5")) 
               {
                   var myPage = myFound[i].parentTextFrames[0].parentPage.name;
                  alert(myPage)
                   }
               
               else if ((myVersion1 == "CS4") || (myVersion1 == "CS3")) 
               {
                    if(myFound[i].parentTextFrames[0].parent.constructor.name== "Page" || myFound[i].parentTextFrames[0].parent.constructor.name== "Spread")
                    {
                        var myPage = myFound[i].parentTextFrames[0].parent.name;
                        alert(myPage)
                        }
                    else if(myFound[i].parentTextFrames[0].parent.paragraphs[0].parentTextFrames[0].parent.constructor.name == "Page" || myFound[i].parentTextFrames[0].parent.paragraphs[0].parentTextFrames[0].parent.constructor.name == "Spread")
                    {
                        var myPage = myFound[i].parentTextFrames[0].parent.paragraphs[0].parentTextFrames[0].parent.name;
                        alert(myPage);
                        }
                    
            //~         else if(myFound[i].parentTextFrames[0].parent.parent.constructor.name == "Page" || myFound[i].parentTextFrames[0].parent.parent.constructor.name == "Spread")
            //~         {
            //~             var myPage = myFound[i].parentTextFrames[0].parent.parent.name;
            //~             alert(myPage);
                        //}
            
                  }
              }
            

             

             

            Please anyone help for my request.

             

            Thanks in advance

            Beginner_X

            • 4. Re: Parent Page in CS4
              Peter Kahrel Adobe Community Professional & MVP

              Follow the link I posted earlier and try Dave Saunders's findPage() function. That's proven to work well.

               

              Peter