0 Replies Latest reply on Nov 15, 2012 2:13 AM by InDesign

    InDesign won't close files

    InDesign Level 1

      Hallo everybody,


      I'm new her at InDesign-Scripting-Forum, but I have a great problem, and hope there is somebody out who can help me:


      My problem is that InDesign won't close files which have been opened.



      Just a little Javascript (I have reduced it to the minimum):



      var myFile="1.indd";


      // Open the file

      var myDoc=app.open(File(myFile));

      // Close the file


      if(app.documents.length > 0)
              alert("Still " + app.documents.length + " files opened");




      If this script starts from InDesign Javascript Panel, there are no problems or errors.

      InDesign will open the file (1.indd), and closes the file, and no alert will appear.


      But.... if the Javascript ist copied to the InDesign "startup script" folder, so that InDesign should
      run this script on InDesign Startup,the alert will appear.


      If you are running the script in a loop, just like working with 10 files of a current directory,

      InDesign will show alert of 10 opened files at the end.


      So.. at the end of the script, I want to move the (opened and closed) file to another directory.

      But when InDesign "says" the file is opened, I cannot move or rename the file.

      (It is only possible when running the script manually by the Javascript Panel).


      Can anybody help me, so that I can close the file, or that InDesign will close the file
      when running as a "startup-script"?


      Thanks very much.