Revert after Getting an Error in an InDesign Script
Sometimes scripts leave "droppings" that need to be cleaned up!
Doug wrote with a problem he was having with the Split Story script (which ships with InDesign, inside the Scripts panel):
When I attempt to run the script it comes up with a javascript error (Number 11274; String: Object is Locked).
He figured out that problem pretty quickly himself… the frames with the threaded story (that he was trying to split) were locked on the master page. But then he discovered a bigger issue:
The problem though, is something I discovered by accident later. It appears that whenever this error box pops up, instead of removing threading it actually duplicates all the threaded text boxes. I discovered up to three separate copies of each text box on each page (far too late to Undo so I had to delete them all manually).
This perfectly illustrates a point every script-user should understand: Running a script is different than choosing a menu item. In many cases (though not all), a script will run through a series of several or many different steps to accomplish its task. Those tasks are actually recorded in InDesign’s Undo history, so you could step back through them if you wanted to.
In the case of the SplitStory script, one of the steps the script takes is to first duplicate each frame in the story. Later, when it tries to delete the original frames, it finds that one of them is locked and it “errors out” — it stops running. But it doesn’t go back and clean up after itself. And even if you Undo once or twice, you won’t get back to the original state.
That’s why it’s often a good idea to choose File > Save before you run a script like this, and if it errors out before it finishes, then choose File > Revert. That puts you right back to square one, ready to fix the problem (then save) and try the script again.
This article was last modified on December 20, 2021
This article was first published on March 25, 2010
