7 Replies Latest reply on Jul 27, 2011 2:44 AM by jeanmed

    page number (search function)

    jeanmed

      Dear,

       

      I need to creat a script who search all  words who use the test character style.

      In my script it works but i dont fond the way to load the page number of the elements founded.

       

      My code :

      var list=new Array();

      app.findTextPreferences = app.changeTextPreferences = null;
      app.findTextPreferences.appliedCharacterStyle = "test";
      return = app.activeDocument.findText();

      var msg="";
      for (i = 0; i < retour.length; i++)
      {
          msg+=return [i].contents+" - "+return [i]. // here the page number //+"\r";
      }

       

      alert(msg);

       

       

      Thanks for your help

        • 1. Re: page number (search function)
          csm_phil Level 4

          Hi Jean,

           

          I have to modified you JS Code, please try and get correct you expect the result.

           

           

          var myDoc = app.activeDocument;
          var list=new Array();
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findTextPreferences.appliedCharacterStyle = "test";
          var mySearch = app.activeDocument.findText();
          var msg="";
          
          
          for (i = 0; i < mySearch.length; i++){
          
          
              msg+=mySearch[i].contents+" - "+mySearch[i].parentTextFrames[0].parent.name+"\r";
           }
          alert(msg);
          

           

           

           

          thanks

          csm_phil

          • 2. Re: page number (search function)
            jeanmed Level 1

            Thanks for your help !

             

            Do you  know how to do search between different pages exemple from 10 to 15.

             

            Thanks a lot

            • 3. Re: page number (search function)
              csm_phil Level 4

              Hi Jean,

               

              i have updated my script as per your above mentioned request.

              Please try this js code and revert for further help?

               

              var myDoc = app.activeDocument;
              var list=new Array();
              var myPage = myDoc.pages;
              app.findTextPreferences = app.changeTextPreferences = null;
               app.findTextPreferences.appliedCharacterStyle = "test";
               var mySearch = app.activeDocument.findText();
              var msg="";
              for (i = 0; i < mySearch.length; i++){
                   try{
                        var mypage = mySearch[i].parentTextFrames[0].parent.name;
                        }catch(e){}
                   if(mypage>=10&& mypage <=15){
                        try{
                             msg+=mySearch[i].contents+" - "+mySearch[i].parentTextFrames[0].parent.name+"\r";
                             }catch(e){}
                        }
                   }
              alert(msg);

               

              thx

              csm_phil

              • 4. Re: page number (search function)
                jeanmed Level 1

                Dear,

                 

                This code dont works width CS5 : mySearch[i].parentTextFrames[0].parent.name

                 

                Do you have an idea ?

                 

                Thanks

                • 5. Re: page number (search function)
                  Adobe-InDesign CS4 Level 1

                  Dear Ieanmed,

                   

                  Please use the below code: CS5

                   

                  //==================== Code=================//

                  mySearch[i].parentTextFrames[0].parentPage.name

                   

                   

                   

                   

                  Regadrs

                  T.R.Harihara SudhaN

                  1 person found this helpful
                  • 6. Re: page number (search function)
                    csm_phil Level 4

                    Hi Jean,

                     

                    You can't mentioned your using CS5, i am giving the code is working in cs3/cs4 only. Because the CS5 give the short method of "parentPage". So hari mentioned the correct way in CS5.

                     

                    You expect the page range is working or not? has i was post my previous code.

                     

                    thx

                    csm_phil

                    1 person found this helpful
                    • 7. Re: page number (search function)
                      jeanmed Level 1

                      Thanks a lot !