5 Replies Latest reply on Mar 28, 2017 8:42 AM by tpk1982

    Find and Replace font with color

    tpk1982 Level 4

      HI All,


      I have a document, which I need to have the english words in a specific font. Otherwise I need to mark with any color. I tried with my script as show below, but it apply wrongly to all words except english character.


      If you provide the solution for my coding or any other method, that would be helpful


      var flag=0;
      function findmymagentatext()
      var w = new Window ("dialog", "BEATS");
      w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});   
      w.p1.add('statictext',undefined,"SELECT DESIRED COLOR"); 
      w.p1.g = w.p1.add('group');  
      w.p1.g.orientation = 'column'
      w.p1.g.alignChildren = "center";
      var swatches=app.documents[0].swatches.everyItem().name;
      var preset_list = w.p1.g.add ("dropdownlist", undefined, swatches);
      w.orientation = "column";
      w.add ("button", undefined, "OK");
      w.add ("button", undefined, "Cancel");
      var myResult = w.show() 
      if(myResult == 1){
             if(flag==0) {alert("No error found");}
          else if (myResult== 2){
      function mychanges(){
      var mycolor=preset_list.selection.text;
      var myarray=[];
      app.findGrepPreferences = null;     app.changeGrepPreferences = null;
      app.findGrepPreferences.findWhat = '[a-zA-Z0-9.,?:;!]';  
      found = app.documents[0].findGrep();  
          for (i=0;i<found.length;i++) {  
                  if((found[i].appliedFont.name!=="ITC Avant Garde Gothic Std\tBook") || (found[i].appliedFont.name!=="ITC Avant Garde Gothic Std\tDemi") || (found[i].appliedFont.name!=="ITC Avant Garde Gothic Std\tMedium")){ 
                      app.changeGrepPreferences.fillColor = mycolor;
               alert("Some Text area applied by wrong font, so it applied with color: "+mycolor);
               return flag;



      Advance Thanks,