Have you tried
Your code works for me.
Ignore my last comment that doesn't work
1 person found this helpful
I ran your code smithy70 and it works fine here. I am using the latest 2015.4 release, 220.127.116.11
Is there a story in an inline in overset text? That could explain the error.
There's a slightly convluted line in your code. For this:
lastFrame = stories[j].texts.parentTextFrames[stories[j].texts.parentTextFrames.length - 1];
this is a bit clearer (and less typing):
lastFrame = stories[j].textContainers.endTextFrame;
So it turns out there is a issue with a text box as the code works on most of the document.
File with offending box here, not sure why it is not working.