2 Replies Latest reply on Sep 22, 2011 5:34 AM by Zoffix222

    Apply Character Style To Few Characters in a Paragraph

    Zoffix222 Level 1



      Me again - I feel like I'm dumber than a shoe trying to script InDesign


      I have a text frame with several paragraphs, which I'm adding one by one.


      While adding these paragraphs, sometimes I need to apply a character style to some of the characters within the paragraph (I have the start and end indices of these characters, relative to the text of the paragraph).


      Using the Scripting Guide and the Object Reference, I concocted this code below, but not only it doesn't seem to locate the character style, it also tells me the .itemByRange() is not a function...


      What's wrong?



      var line_styles = [{
          'start': 22,
          'end': 33,
          'style': 'Price - SKU'
      frame.contents += "\r" + line_text;
      for ( var j = 0, k = line_styles.length; j < k; j++ ) {
          var char_style = doc.characterStyles.item(line_styles[j].style);
          ).applyCharacterStyle(char_style, true);