2 Replies Latest reply on Dec 22, 2009 8:12 PM by Yuliaart

    Save and close InDesign file CS4 JS

    Yuliaart Level 1

      Hi, I need to save and close InDesign file after export pdf was done. Once export is complete the script opens the pdf file and the script gets interrupted. Here what I was trying and I am not sure if it even in the right direction:

       


      #targetengine "session"
      main();


      function main(){
          var myApplicationEventListener = app.eventListeners.add("afterExport",
          mySaveInDesign, false);
          var myDocumentEventListener = app.documents.item(0).eventListeners.add
          ("afterExport", mySaveInDesign, false);
          app.scriptPreferences.version = 6.0;
      var myEventNames = ["afterExport"] ;
          }

       

      function mySaveInDesign(myEvent){
          var myDocument = myEvent.parent;
          saveInDesign ();
      }

       

      function saveInDesign (){
          //myDocument.save(myDocument);
          app.activeDocument.save(myDocument);
          app.activeDocument.close(myDocument);
          }

       

      Your help is highly appreciated.

      Yulia