1 Reply Latest reply on May 29, 2008 1:45 PM by (Olav_Kvern)

    How can i get the current number of word in paragraph?

      I have cursor set on some word in Para. And i'd like to make italic all words before it. How can i get the number of current word in collection Words in mInd.Selection.Item(1)?
        • 1. Re: How can i get the current number of word in paragraph?
          Level 1
          Hi Dmitry1776,

          Try something like this:

          Set myInsertionPoint = myInDesign.Selection.Item(1)
          Set myStory = myInsertionPoint.ParentStory
          Set myStartCharacter = myStory.Characters.Item(myInsertionPoint.Paragraphs.Item(1).Index)
          Set myCharacter = myStory.Characters.Item(myInsertionPoint.Index)
          Set myEndCharacter = myStory.Characters.Item(myCharacter.Words.Item(1).Index - 1)
          Set myText = myInsertionPoint.ParentStory.Texts.ItemByRange(myStartCharacter, myEndCharacter).Item(1)

          ...at this point, myText is a range of text from the start of the paragraph to just before the text containing the insertion point.

          Thanks,

          Ole