Skip navigation
Currently Being Moderated

Another glitch in script using Style Groups

Jan 27, 2011 9:16 AM



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;


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points