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.
var myApplicationEventListener = app.eventListeners.add("afterOpen",checkWPSTables, false);
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?