7 Replies Latest reply on Mar 27, 2017 2:42 AM by Qwertyfly...

    Script: "No such Element" error when looking for a specific paragraph

    philippeb42842826

      Hello,

       

      I've searched an answer to this everywhere, but in vain... My script looks for a specific paragraph in a textframe, based on its index in TextFrame.Paragraphs. So far so good, but in one of the files I ran my script on, it keeps blocking on a specific textframe when looking for the second paragraph in it.

       

      I tried testing first that the index of the paragraph was within the TextFrame.Paragraphs.Count, but even so, it doesn't work : it confirms the textframe hold 2 paragraphs (TextFrame.Paragrephs.Count=2), but insists that TextFrame.Paragraphs(2) doesn't exist.

       

      I twisted and turned my code around, trying to figure out why, in vain so far. And when looking at the textframe with the hidden characters shown, it shows clearly the two paragraphs, so I don't understand what happens here...

       

      Here's a snippet of my code, where the error occurs:

       

      paraNb = Cint(Para)

      paraCnt = docTF.Paragraphs.Count

      If paraNb > 1 Then

           If paraNb = paraCnt Then

                test = True

           End If

      End If

      Set docPar = docTF.Paragraphs(paraNb) 'This is where the error occurs