2 Replies Latest reply on Mar 9, 2015 7:39 PM by briank84322880

    Applescript—Apply Character Style to Select Words in InDesign CC


      I'm trying to apply a character style to the first several words of a paragraph. The number of words varies, but it is essentially every word before a comma.



      Here's what I have so far:



      tell application "Adobe InDesign CC 2014"

        tell document 1

        tell page 2

        tell (item 1 of page items whose label is "HabitsContent")

        tell paragraph 2

        repeat with i from 1 to count of characters

        if contents of character i = "," then

        exit repeat

        end if

        end repeat

        set applied character style of characters 1 thru i to "Italic"

        end tell

        end tell

        end tell

        end tell

      end tell



      Viewing the log of the script, it finds the comma; however, the script ends up italicizing the entire paragraph. Any ideas?