2 Replies Latest reply on Feb 4, 2013 1:43 PM by jkinsman

    No documents open error received after "afterOpen" event.

    boise_codeJunky

      I'm trying to run a script to check data in tables against a data source.  So I need to be able to scan the tables when the document is opened.  The scanning and updating script I made works great.  It's just the initialization of the script when a document is opened is not working.

       

      main();

       

      function main(){
         var myApplicationEventListener = app.eventListeners.add("afterOpen",checkWPSTables, false);
      }

       

      function checkWPSTables(myEvent){
          var myDoc = app.activeDocument;  //This throws the error.

          //........

      }

       

      The error it throws is "No documents are open."

       

      The script is placed properly in the Startup Scripts folder.

       

      So it seems there is no active document at this stage of the event propogation.  Is there a way to solve this?