Skip to main content
Known Participant
January 19, 2015
Answered

Loop through styles not working as intended.

  • January 19, 2015
  • 1 reply
  • 351 views

I'm trying to loop through all the styles in a number of documents and locate any styles with the font "Times New Roman (OTF)." Unfortunately, no matter how I tweak the script, it won't trigger the alert where and when it should. Any ideas? Thanks!

var myDocument = app.activeDocument;

for (a=1; a < myDocument.allParagraphStyles.length; a++) {

    if(myDocument.allParagraphStyles.appliedFont == "Times New Roman (OTF)") {alert()}

    };

for (b=1; b < myDocument.allCharacterStyles.length; b++) {

    if(myDocument.allCharacterStyles.appliedFont == "Times New Roman (OTF)") {alert()}

    };

This topic has been closed for replies.
Chinnadk
ChinnadkCorrect answer
Legend
January 19, 2015
CambLSATAuthor
Known Participant
January 19, 2015

Thanks! That works.