1 Reply Latest reply on Sep 13, 2011 12:47 PM by Paul Chernoff

    Finding location of selection in InCopy [AppleScript]

    Paul Chernoff Level 1

      This is a variation of my request from yesterday. I am able to select the last character of the last column of the story. I now want to know the location of that character.

       

      For example, I find the last character with this lin of code

       

      select text of last character of last word of last text column of myStory

      I then put the seleciton in a variable

      set mySelection to selection of myDocument

      mySelection is a list. The first object has the following definition:
      text from character 1108 to character 1108 of story id 37515 of document id 7
      But I cannot figure how to get the the character number (1108) into a variable.
      Any ideas?

        • 1. Re: Finding location of selection in InCopy [AppleScript]
          Paul Chernoff Level 1

          I have some of my answer. I set a variable to the index of the given character. See below.

           

          tell application "Adobe InCopy CS5"

          set myDocument to active document

          set mySelection to selection of myDocument

          set myTextObject to item 1 of mySelection

          set myStory to parent story of myTextObject

          set myOverset to overset text of myStory

          set myText to index of last character of myTextObject

          set howMany to count characters of myStory

          select character 20 of myStory

          end tell

           

          Now to figure out how to select a selection of text.

           

          This works:

          select character 20 of myStory

          This doesn't:
          select characters 20 through 30 of myStory