3 Replies Latest reply on Feb 12, 2014 7:42 AM by Trevorׅ

    Change the characterstyle in all textframes

    Alexan.K

      Hello all,

       

      i have a problem in my javascript script. I want a script that check all textframes in the document and it have to check the characterstyle from each char.

      If there is a "-" in the text, the characterstyle will switch to normal. The problem is that i did not find the text in the textframe with the javascript. I´m new in the business.

      I think my approach is wrong, but i can´t find an another one.  

       

      My code :

       

      var doc = app.activeDocument;

      var tf = doc.textFrames.anyItem();

      var paras = tf.paragraphs.everyItem().getElements();

      var applied_style = doc.characterStyles.itemByName('Cent');

       

       

      var paras_with_style = [];

      for (var i=0,l=paras.length; i<l; i++) {

         var para = paras[i];

         if (para.appliedCharacterStyle == applied_style) {

            var contenttext = para.contents;

                  if (contenttext == "-") {

                          para.changeTextPreferences.position = Position.normal;

                  }

        else {

                          para.changeTextPreferences.position = Position.superscript;

                  }

         }

      }

       

      Thanks for your help

       

      Greets Alex