2 Replies Latest reply on Apr 26, 2013 3:28 PM by foredit

    Finding text section by section

    foredit

      Hi my friends, here again with a new question.

      Looking for superscript text I have no problem using text selection or xml tags but no way performing this section by section.

      Here's a piece of the script i'm workin on ...it stops with error at the red line

       

          var mySec = app.activeDocument.sections.count();

          alert ("Sections in document: " + mySec);

          for (s=0; s<=mySec -1; s++) {

          var mySecItm = app.activeDocument.sections.item(s);

          alert ("Pages in section " + (s+1) +": " + mySecItm.length);    

          app.findGrepPreferences = app.changeGrepPreferences = null;

          app.findGrepPreferences.position = Position.SUPERSCRIPT;

          app.findGrepPreferences.findWhat = ".+";

          var apici = app.activeDocument.sections.item(s).findGrep();

          alert ("Section " + (s+1) +" contains " + apici.length + "superscript");

          }

       

      Any idea will be appreciated

      Thank you

        • 1. Re: Finding text section by section
          Jump_Over Level 5

          Hi,

           

          a page, spread or section can not be a target for find.Grep() method.

           

          It can be processed with app, doc, story, textFrame, table and so on lower level objects.

           

          I suggest to modify this part:

          var apici = app.activeDocument.findGrep();
          var Res = [];
          var l = apici.length;
          while (l--)
               if (apici[l].parentTextFrames[0].parentPage.appliedSection == mySecItm)
                    Res.push(apici[l]);
          

          so finally array Res should collect all proper found texts

           

          rgds

          Jarek

          • 2. Re: Finding text section by section
            foredit Level 1

            Straight to the point ...another great lesson in script for me (have to study now!).

             

            Thank you Jarek