1 Reply Latest reply on Jul 23, 2014 12:16 PM by pixxxel schubser

    Unfunction of Script

    Math Kay Level 1

      This is script is showing number of paragraphs only.Style is not applying. Please resolve it.

       

       

      var myDoc=app.activeDocument;

       

      var myPara=app.activeDocument.textFrames.item(0).paragraphs.everyItem().getElements();

      alert(myPara.length);

       

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

           if(myPara[i].pointSize="12pt")

           {

               myPara[i].appliedStyle="TX"

            } 

          }  

        • 1. Re: Unfunction of Script
          pixxxel schubser Level 5

          @Math Kay,

          to compare use the double == (and not with the simple one).

           

          Try this:

          var myDoc=app.activeDocument;
          var myPara=app.activeDocument.textFrames.item(0).paragraphs.everyItem().getElements();
          //alert(myPara.length);
          for(i=0; i<myPara.length; i++){
               if(myPara[i].pointSize==12)
               {
                   myPara[i].appliedParagraphStyle="TX";
                }
              }
          

           

          But be sure that the paragraph style "TX" already exists in your document. Otherwise the script fails.

           

          Have fun