2 Replies Latest reply on Apr 4, 2013 1:17 AM by Cooroo

    Applescript: Working with text

    Cooroo

      My script finds blocks of text which are have the character style "CS-Descriptor":

       

      tell application "Adobe InDesign CS5"

      set applied character style of find text preferences to "CS-Descriptor"

                tell document 1

                          set myDescription to find text

                end tell

        end tell

       

      This returns, e.g.

      {text from character 1807 to character 1818 of story id 21888 of document id 19 of application "Adobe InDesign CS5"}

      I now need to find more information about the immediate surroundings of this piece of text. Somehow I want to find out something like the paragraph number, or line number, so that I can find the first word of the line.

       

      Can anyone help me get from 'text from character......' to 'paragraph 52 of text flow.... ' or something similar?

       

      So far scripting ID my experience has been that it is much, much easier than I think! Fingers crossed it is again.

       

      Sorry about Applescript - it seems to be dying out!

       

      Emma

        • 1. Re: Applescript: Working with text
          sstanleyau Level 4

           

          Cooroo wrote:

           

          This returns, e.g.

          {text from character 1807 to character 1818 of story id 21888 of document id 19 of application "Adobe InDesign CS5"}

          I now need to find more information about the immediate surroundings of this piece of text. Somehow I want to find out something like the paragraph number, or line number, so that I can find the first word of the line.

           

          You can just ask for :

           

                    word 1 of paragraph 1 of myDescription


          Getting the paragraph number is a bit trickier:

           

            count of paragraphs of text from character 1 of parent story of myDescription to character 1 of myDescription

           

          Sorry about Applescript - it seems to be dying out!

           

          Nothing to apologise for -- reports of its death have been greatly exaggerated.

          • 2. Re: Applescript: Working with text
            Cooroo Level 1

            Thank you! That works perfectly and my (much bigger) script can advance!