Clarification needed for Event Listener
Hi All,
I am trying to use event listener to import character styles from my template. I placed this script in startup script. My problem is the confirmation message come twice everytime. Can you please anyone solve this?
#target indesign
#targetengine "session"
var
myEventListener = app.eventListeners.item("loadstyles");
if (!myEventListener.isValid) {
myEventListener = app.addEventListener( "afterOpen", doJob );
myEventListener.name = "loadstyles";
}
function doJob() {
if (!app.documents.length) return;
var myconfirm=confirm("It is Live job?");
if( myconfirm){
var theDocument = app.activeDocument;
var sourceFile = new File(".../dummt text.indd");
//import paragraph styles
var paraImport = ImportFormat.CHARACTER_STYLES_FORMAT;
//This will import without overwrite existing styles.
var clashPolicy = GlobalClashResolutionStrategy.DO_NOT_LOAD_THE_STYLE;
theDocument.importStyles(paraImport, sourceFile, clashPolicy);
}
}
Thanks in advance.
Karthik