1 Reply Latest reply on Oct 8, 2014 5:28 AM by BEGINNER_X

    How to string add paragraph styles all page only  certain style

    hamdifem Level 1

      paragraph style (A1style) per the "Like" I want to add

       

      var myDoc = app.activeDocument;

      var myParaStyle = "A1style";

       

      for (p=0; p<app.activeDocument.pages.length; p++) 

          for (t=0; t<app.activeDocument.pages[p].textFrames.length; t++) 

          { 

                  app.activeDocument.pages[p].textFrames[t].insertionPoints[0].contents = "Like"; 

                  if(textFrames[t].appliedParagraphStyle == myParaStyle) {

                }

          } 

        • 1. Re: How to string add paragraph styles all page only  certain style
          BEGINNER_X Level 3

          Hi,

           

          Hope this is your requirement,

           

          app.findGrepPreferences = app.changeGrepPreferences = null;
          
          app.findGrepPreferences.appliedParagraphStyle = "A1style"
          
          app.findGrepPreferences.findWhat = ".+";
          
          app.changeGrepPreferences.changeTo = "LIKE $0"
          
          app.activeDocument.changeGrep();
          
          

           

          Alternate Way,

           

          var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();
          
          alert(myParas.length)
          
          for(i=0; i<myParas.length; i++)
          {
              if(myParas[i].appliedParagraphStyle.name == "A1style")
              {
                  app.select(myParas[i])
                  app.selection[0].insertionPoints[0].contents = "LIKE ";
                  }
              }
          

           

          Regards

          Siraj