Reply To: changegrep misses final match

Home Page / Forums / General InDesign Topics (CLOSED) / changegrep misses final match / Reply To: changegrep misses final match

#125753

More info:
The problem is somewhat intermittent: Occasionally the script works as expected, and sometimes changegrep misses the last two or even three matching paragraphs.
This made me wonder if there’s a problem with asynchronous execution, such that the changegrep commands are running before the earlier commands are finished building the text frame.
I moved the code snippet to the bottom of the script to execute after a couple of other things that take two or three seconds. This appeared to help–changegrep worked more often–but it’s not a “solution” because I need certain things to happen before others.
I put the snippet back where it belongs, and inserted a “fit frame to content” command just before it:
textframe.fit(FitOptions.FRAME_TO_CONTENT);
This seems to have solved the issue … perhaps “fit” waits for InDesign to finish building the text frame before executing and allowing the script to continue.

This article was last modified on July 4, 2020

Comments (0)

Loading comments...