3 Replies Latest reply on Jan 18, 2015 10:58 PM by Chinnadk

    İn group object applied script

    hamdifem Level 1

      In one document, a text frame object style is applied, does not apply if the script with an object group.

      How can I solve this problem     

       

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

          if(myBox[i].appliedObjectStyle == myStyle01) {

              app.findGrepPreferences = app.changeGrepPreferences = null; 

              app.findGrepPreferences.findWhat = "A"; 

              app.findGrepPreferences.fillColor = "Color01";

              app.changeGrepPreferences.changeTo  = "X"; 

              myBox[i].lines[0].texts[0].changeGrep(); 

              app.findGrepPreferences = app.changeGrepPreferences = null; 

          }

      }

       

      image.jpg

        • 1. Re: İn group object applied script
          Chinnadk Level 4

          Try this,

           

          var doc = app.activeDocument;
          var myBox = doc.allPageItems;
          for(var i=0;i<myBox.length;i++)
          {
                  if(myBox[i] instanceof TextFrame)
                  {
                          if(myBox[i].appliedObjectStyle.name == "myStyle01")
                          {
                                  app.findGrepPreferences = app.changeGrepPreferences = null; 
                                  app.findGrepPreferences.findWhat = "A"; 
                                  app.findGrepPreferences.fillColor = "Color01";
                                  app.changeGrepPreferences.changeTo  = "X"; 
                                  myBox[i].lines[0].texts[0].changeGrep(); 
                                  app.findGrepPreferences = app.changeGrepPreferences = null;
                              }
                      }
              }
          

           

          Regards,

          Chinna

          • 2. Re: Re: İn group object applied script
            BEGINNER_X Level 3

            Hi Hamdifem,

             

            I did a small modifications in chinna provided script (2nd line)

             

            Hope this will provide you the better result.

             

            use this below for the line 2

             

            var myBox = doc.textFrames.everyItem().getElements(); 

             

            Regards

            Siraj

            • 3. Re: İn group object applied script
              Chinnadk Level 4

              Hi Siraj,

               

              var myBox = doc.textFrames.everyItem().getElements(); this will return textFrames of the document but it excludes if the textFrames those are in the groups.

               

              Regards,

              Chinna