Copy link to clipboard
Copied
Anyone know how to revert (or re-open) a document at the end of a script?
Cheers
Just close it without saving, then reopen.
Here's the script in VB.NET, but you'll get the idea.
Dim aDoc As AI.Document = app.ActiveDocument
Dim fullName As String = aDoc.FullName
aDoc.Close(AiSaveOptions.aiDoNotSaveChanges)
app.Open(fullName)
Hope this helps.
-TT
Copy link to clipboard
Copied
Just close it without saving, then reopen.
Here's the script in VB.NET, but you'll get the idea.
Dim aDoc As AI.Document = app.ActiveDocument
Dim fullName As String = aDoc.FullName
aDoc.Close(AiSaveOptions.aiDoNotSaveChanges)
app.Open(fullName)
Hope this helps.
-TT
Copy link to clipboard
Copied
Thanks, I've found myself at a similar solution. I'm working in Javascript...
This works:
function revertDoc() {
var docsource = activeDocument.fullName;
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.open(docsource);
}
Copy link to clipboard
Copied
Actually, mine works just fine in Javascript too.
TestScript();
function TestScript() {
var aDoc = app.activeDocument;
var fullName = aDoc.fullName;
app.activeDocument.close (SaveOptions.DONOTSAVECHANGES);
app.open (fullName)
}
Have you tried closing AI and reopening it and running the script fresh? AI notes that there are suggested limits for the number of times that you can open/close documents (can't put my finger on it now) -- might be worth a try.