It looks to me that you are adding two event listeners in this code. The first one, you're attaching to the application. That's the one that is causing your error. Try just deleting (or commenting out) that line.
It looks to me that the one causing the error is the one being
attached to the document. You can't attach event listeners to
documents in startup scripts since there's no documents open yet...
Either way, there's no reason to be attaching event listeners to both
the app and a doc. If it's a startup script, just attach it to the
After commented, my code look like this
var myApplicationEventListener = app.eventListeners.add("beforeImport",
/*var myDocumentEventListener = app.documents.item(0).eventListeners.add
("beforeImport", myEventInfo, false);*/
var myString = "Current Target: " + myEvent.currentTarget.name;
It will not invoke, when i import xml file to the template.
I have placed startup script folder.
Any other modification i want to do?
1 person found this helpful
I think you need to attach your listener to the ImportXML... menu action.
Now my code is
var myCloseMenuAction = app.menuActions.item("Import XML...");
var myEventListener = myCloseMenuAction.eventListeners.add("beforeInvoke",myBeforeInvokeHandler, false);
alert('yes, it is working');
It is working fine, Thanx.