5 Replies Latest reply on Dec 10, 2012 9:47 PM by shilpa25

    Help!....Apply fillColor to desired text (Qc purpose)

    shilpa25 Level 1

      Hi Forum,

       

      I have written script for applying color to the desired text.... but nothing happens.... ESTK says: "execution finished, result is 'r'".

       

      (the document has some character styles applied to the desired text and on some of the desired text character styles left unapplied...

       

      my motive is to find the unapplied character styles on the desired text and highlight them using red colour... (for QC purpose)

       

       

      myDoc = app.documents.item(0).stories.everyItem().paragraphs.everyItem().characters;

      var mytexts = "You |you |your |Your |us |our |Our"  //desired texts on which character styles left unapplied on some pages..

      for (i = 0; i<mytexts.length; i++) {

      mytext = mytexts[i];

      if (mytext.appliedFontStyle == "Regular") {  // if the text has "None" character style applied on it.... then fill... "Red"

          mytext.appliedFillColor = "Red";

          }

      }

       

       

      any help on this....

       

      thanks...

        • 1. Re: Help!....Apply fillColor to desired text (Qc purpose)
          csm_phil Level 4

          Hi Shilpa25,

           

          I have the small trick for the above request. try this.

           

           

          app.findGrepPreferences = NothingEnum.nothing;
          app.changeGrepPreferences = NothingEnum.nothing;
          
          app.findGrepPreferences.findWhat = "(?i)(your|you|our)";
          app.findGrepPreferences.fontStyle = "Regular";
          app.changeGrepPreferences.fillColor = "Red"
          app.changeGrep();
          
          app.findGrepPreferences = NothingEnum.nothing;
          app.changeGrepPreferences = NothingEnum.nothing;
          

           

           

          thx,

          csm_phil

          • 2. Re: Help!....Apply fillColor to desired text (Qc purpose)
            Jump_Over Level 5

            Hi,

             

            No chance to work this way.

            (I mean Shilpa way, didn,t see your answer csm_phil )

             

            1. mytexts suppose to be an array to iterate into. Otherwise you are iterating through characters, one by one.

                 so make it mytexts = mytexts.split("|");     // here is an array

             

            2. you have to find every occurence of each "mytexts" element inside your doc to check if CharStyle is added;

            then you can use find...change to reach your goal.

              So make inside your "for_loop":

             

                 app.findTextPreferences = null;

                 app.changeTextPreferences = null;

                 app.findTextPreferences.findWhat = mytext;

                 app.findTextPreferences.fontStyle = "Regular";     //are you sure "Regular" fontStyle is a good sign for action?

                 app.changeTextPreferences.fillColor = "Red";     //make sure there is "Red" color in your doc

                 app.activeDocument.changeText();

             

            this should work.

             

            enjoy

             

            Message was edited by: Jump_Over

            • 3. Re: Help!....Apply fillColor to desired text (Qc purpose)
              shilpa25 Level 1

              hi Jump_over,

               

              thanks very much, for the edits, it also works now as that of csm_phil.

               

              what is the difference between, csm_phil find and change comparig with yours.

               

              It would be great if i have clear update on your..

               

              thanks in advance..

              • 4. Re: Help!....Apply fillColor to desired text (Qc purpose)
                Jump_Over Level 5

                Hi,

                 

                Phil way is a smarter one.

                It find all occurences of your text (match case switched off) using GREP regular expression (all at once) and change it in the same step (all at once).

                 

                Notice that   app.changeGrep();
                do it in every document currently opened in InDesign.

                 

                rgds

                • 5. Re: Help!....Apply fillColor to desired text (Qc purpose)
                  shilpa25 Level 1

                  thanks ya!

                   

                  a great explanations....

                   

                  shil...