I have Infopath form that contains some fields with data. Also I have Indesign application that have a blank document.
I use this to use indesign as activex object:
var id = new ActiveXObject("Indesign.Application");
I use this construction to determine if a document is open in indesign:
try {var myDoc = activeDocument}
catch (error) {XDocument.UI.Alert("no open files in indesign");}
Here i have some code to run if there is a document opened.
So if there is no opened documents in indesign, I need to stop script running.