Completing track changes before export
I am trying to accept all changes in a document, and then export the result to IDML. (goal is to perform the task on a batch of files at the same time).
I am using the following code:
app.documents[0].stories.everyItem().changes.everyItem().accept();
exportIdm(app.documents[0]);
function exportIdml(theDocument)
{
myFilePath = theDocument.name + ".idml";
myFile = new File(myFilePath);
theDocument.exportFile(ExportFormat.INDESIGN_MARKUP, myFile, false);
}
If I try only to accept all changes, or simply to export IDML, with part of the above code, I get expected result.
However, if I run both in the same script, InDesign hangs, and I get an invalid frame when InDesign restart and recover the document.
It looks like the app.documents[0].stories.everyItem().changes.everyItem().accept() action is not completely committed before the next function is called.
Note that in my test document, there are a large number of changes, including over 600 frames tracked for deletion, which can be a contributing factor.
Any clue on how I can force the accept() to complete and commit the changes before running the IDML export?