Skip to main content
Inspiring
July 23, 2014
Answered

Unfunction of Script

  • July 23, 2014
  • 1 reply
  • 237 views

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.pointSize="12pt")

     {

         myPara.appliedStyle="TX"

      } 

    }  

This topic has been closed for replies.
Correct answer pixxxelschubser

@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.pointSize==12)

     {

         myPara.appliedParagraphStyle="TX";

      }

    }

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

Have fun

1 reply

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
July 23, 2014

@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.pointSize==12)

     {

         myPara.appliedParagraphStyle="TX";

      }

    }

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

Have fun