3 Replies Latest reply on May 16, 2014 7:16 AM by ThinkingThings

    Revert document?

    mrblix

      Anyone know how to revert (or re-open) a document at the end of a script?

       

      Cheers

        • 1. Re: Revert document?
          ThinkingThings Level 1

          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

          • 2. Re: Revert document?
            mrblix Level 1

            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);

            }

            • 3. Re: Revert document?
              ThinkingThings Level 1

              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.