Copy link to clipboard
Copied
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
Once again, my bad, I should also have posted my answer here, and not only in my other post...
The problem was with variable types: I was casting my variable paraNb as an Integer, when Paragraphs() requires a Double.
As long as paraNb value was 1, it was still OK, but as soon as it got to 2, Illustrator couldn't take it as a Double, it was obviously an Integer.
The issue here should have been reported as wrong type, which would have pointed me in the right direction from the start, but Illustrato
...Copy link to clipboard
Copied
it's not something as simple as the index starting with 0, is it?
Copy link to clipboard
Copied
No, it works perfectly with the other textframes, that contains only 1 paragraph, and docTF.Paragraphs(paraNb) with paraNb=1 causes no error. On another file, where a textframe includes 8 paragraphs, there was no error either, that's why I don't understand why I get this error...
Copy link to clipboard
Copied
i'd suggest you take this over to the scripting board, in that case. i'll see if i can find a mod to move it.
Copy link to clipboard
Copied
My bad, should have thought about it in the first place. I copied my post there.
Copy link to clipboard
Copied
i would guess there is something about that text frame that has illy confused.
if you copy the text to a notepad app. then draw a new text frame and re copy and paste the text back in to illy does it still wig out on the same frame?
after that i would be trying to see if there is something strange in the formatting, special chars or something. maybe add a 3rd parragraph. and or remove the gap between 1 and 2 combining them into 1 parragraph. at each stage query the dom to see whats going on.
Copy link to clipboard
Copied
Once again, my bad, I should also have posted my answer here, and not only in my other post...
The problem was with variable types: I was casting my variable paraNb as an Integer, when Paragraphs() requires a Double.
As long as paraNb value was 1, it was still OK, but as soon as it got to 2, Illustrator couldn't take it as a Double, it was obviously an Integer.
The issue here should have been reported as wrong type, which would have pointed me in the right direction from the start, but Illustrator reported it as though Paragraphs(Int) is an unknown element (when Paragraphs(Dbl) isn't)...
Anyway, I corrected my cast in paraNb = CDbl(Para) and haven't had any issue with it ever since.
Copy link to clipboard
Copied
thanks for posting back your results.
i work mainly with javascript, and i had not even thought about type of variable.