Well, you're in a bind -- because you've wrapped everything up in a
fastEntireScript, that effectively makes the entire script a single undo
step. So when you call app.undo(), you're undoing the entire script,
which is probably not what you want.
Incidentally, fastEntireScript used to be very buggy -- the
recommendation is to us entireScript. Not sure if that was fixed for the
Anyway, the only idea I have is to nest what you need to undo in a
UndoModes.SCRIPT_REQUEST. Perhaps that way you will be able to undo that
You may want to reconsider why your script needs to undo anything
anyway. It sounds an inefficient way to write a script, although I can
see that for a quick one-off it may be the simplest way of doing some
Thanks for your fast reply.
you're undoing the entire script, which is probably not what you want.
Undoing everything embedded in my "main" function is really what I want to achieve.
Whether it's a bunch of complex code, or nothing at all (as in my snippet, where "main" contains only a comment line ), it's what I want.
the recommendation is to us entireScript
I changed my "UndoModes.fastEntireScript" into "UndoModes.entireScript", as you suggested; with no avail so far: I still get the same "is not a function" error.
Actually, I have the feeling that I do not understand/master the InDesign DOM here, and am simply trying to make a call to a method (undo) which does not exist in this class (app) - despite the Adobe Reference Manual says it does...
It sounds an inefficient way to write a script
My script makes some changes in an InDesign document ("main" function), then exports it to PDF (out of the "main" function).
Then, the environment I work with (XMPie) will inject variable information in the InDesign document for the next recipient.
At this time, I need the document to be reset to its original design.
That's why I need to undo all the changes applied by the "main" function.
I think I already tested your syntax (as I found some references to it in some other Adobe-related forums).
It did not work at this time and, unfortunately, does not work neither now.
The error is "The object does not support the activeDocument property or method" (this text is my translation back from French to English).
Please notice that, obviously, my script can properly access the document, with
also fails with "app.documents.item().undo is not a function".
app.documents.undo ( );
"app.documents.undo is not a function"
I think you cannot undo an Export to PDF.
So app.undo() or app.documents.undo() will not work.
Instead you could save the document before doing the export, close it without saving after the export and re-open it again.