8 Replies Latest reply on Aug 2, 2009 9:12 PM by sstanleyau

    [AS] [CS4] Paragraph number of found text reference

    L. Guy O'Rojo Level 2

      Hi:

       

      Using the script below, I can find a name in a very long story, spread out over many pages. I get a reference to the found text in the form of "text from character 200117 to character 200137 of story id 172155 of " etc.

       

      The find is pretty fast. My question is, how do I determine the number of the paragraph (the index?) that contains this text? The found text will always be within one paragraph. I'm looking for a single number result, for example, "8,447" -- it's the 8,447th paragraph of the story. Doing a counting test from the beginning of the story would be too slow I think. I couldn't find a quick "paragraph index" property in the docs. Any ideas appreciated.

       

      Thanks,

       

      egr

       

       

       

      set findWhat to "Smith, Jr., Mary E."

       

      tell application "Adobe InDesign CS4"

      tell active document

      tell application "Adobe InDesign CS4" to set find text preferences to nothing

      tell application "Adobe InDesign CS4" to set change text preferences to nothing

      tell application "Adobe InDesign CS4" to set find what of find text preferences to findWhat

      set fw to find text

       

      -- return item 1 of fw -->  {text from character 200117 to character 200137 of story id 172155 of document "longdoc.indd" of application "Adobe InDesign CS4"}

       

      -- what is the number of the paragraph?

       

      end tell

       

       

      end tell