I am trying to set up a listener for InDesign, so that every time a doc is opened, "Overprint Preview" is turned on. I have the following script saved in the InDesign Startup Scripts folder:
//*******************************************
#targetengine 'session'
main()
function main()
{
var myApplicationEventListener = app.addEventListener('afterOpen', myafterOpenHandler, false)
}
function myafterOpenHandler(myEvent)
{
//turn Overprint Preview on
var myMenuAction = app.menuActions.item("$ID/Overprint Preview")
myMenuAction.invoke()
}
//*******************************************
The menu invoke works by itself just fine, if a doc is open.
But the script itself errors, just before the doc opens, presumably because the menu is not available yet, since the doc is not showing. The error is as follows:
JavaScript Error!
Error Number: 53762
Error String: Action is not enabled.
Line: 27
Source: myMenuAction.invoke()
Any ideas on this?????