Copy link to clipboard
Copied
Hi all,
I'm trying to sort out this bit of code that checks if a named file is open in InDesign. When the indd isn's open it's throwing an error.
Error String: Object is invalid
if( app.documents.itemByName(" RH KEEP ME.indd").visible == true )
{
alert("Found it");
}
else
{
alert("Not found");
}
What have I gone and done this time?
Many thanks in advance if you can help.
Hi @JustyR, this is how I would do it:
var myTargetDoc = app.documents.itemByName(" RH KEEP ME.indd");
if (myTargetDoc.isValid) {
alert("Document is open.");
}
else {
alert("Document isn't open.");
}
- Mark
Copy link to clipboard
Copied
Hi @JustyR, this is how I would do it:
var myTargetDoc = app.documents.itemByName(" RH KEEP ME.indd");
if (myTargetDoc.isValid) {
alert("Document is open.");
}
else {
alert("Document isn't open.");
}
- Mark
Copy link to clipboard
Copied
Thanks, Mark. That's great.