7 Replies Latest reply on Sep 27, 2016 12:53 AM by jakec88782761

    object contains no text for Find/Change

    jakec88782761 Level 1

      I'm trying to run this script to select text if it is found but it says there no text even though I've wrapped it in an if statement.

       

      function seeSection () { 

          app.findGrepPreferences=app.changeGrepPreferences=null; 

        app.findGrepPreferences.findWhat= "the (section\\s+?\\d+?[\\.\\d+]?)"; 

           app.changeGrepPreferences.changeTo="$1";

          app.changeGrepPreferences.appliedCharacterStyle="cross reference";

            if (app.activeDocument.findText()){

                found.select();

                };

         var changes1 = app.activeDocument.changeGrep();

          if (changes1.length===1){

      alert(changes1.length+" instance of 'the section' was changed to 'section'.");

      }else{

         alert(changes1.length+" instances of 'the section' were changed to 'section'.");

        }

          };