1 Reply Latest reply on Mar 15, 2013 4:52 AM by Vamitul

    How to apply CharacterStyle to a substring of text?

    maxhodges0 Level 1

      How can I select a substring of text from my Cell, so that I can apply a character style

      I'm using vb scripting, but javascript examples are welcome too!

      This works fine when I'm only selecting a single character:

      If IsNumeric(para.Contents.ToString.Substring(0, 1)) doc.Selection = para.Characters.ItemByRange(1, 1) doc.Selection.Item(1).appliedCharacterStyle = mycharstyle End If

      but it fails if I try to select a range of characters

      doc.Selection = myCell.Characters.ItemByRange(72, 76)

      The error is

      Invalid valid for set property 'Selection. Expected Array of Objects, Object or idNothingEnum enumerator, but received (Character, Character, Character, Character, Character)

      I think there must be some entirely different technique to apply my CharacterStyle to a substring of text in my Cell, but after searching high-and-low I've yet to discover it.