0 Replies Latest reply: Jan 27, 2011 9:16 AM by confused_again RSS

    Another glitch in script using Style Groups

    confused_again Community Member



      Everythig was going fine till it started to get complex. I was hoping to adapt a script for cleaning up multiple character styles so that it would work with character styles in a style group, but I get an undefined variable error. Not quite sure how to get round this. It fails on line 3 of the below (this has been simplified for clarity). I'm obviously missing something in terms of defining the Style Group properly as a variable (I get the error "undefined is not an object"). What have I missed?


      var CharStyle = app.activeDocument.characterStyleGroups.item(STYLE GROUP NAME').characterStyles.item['STYLE 1', 'STYLE 2', 'STYLE 3'];
      var myFind = ['(?<=\\w)\\s(?!.)', '(?<=.)[,;:\\.]\\s?(?!.)', '(?<!.)\\s(?=.+)', '(?<!.)[\\s,;:\\.](?!.)'];
      for (var i = 0; i < CharStyle.length; i++){
      app.findGrepPreferences.appliedCharacterStyle = CharStyle[i];
          for (var k = 0; k < myFind.length; k++){
          app.findGrepPreferences.findWhat = myFind[k];
          var f = app.activeDocument.findGrep();
              for (var j = 0; j < f.length; j++){
              f[j].appliedCharacterStyle = myDoc.allCharacterStyles[0];
              f[j].fillColor = f[j].appliedParagraphStyle.fillColor;