When working with multiple open Photoshop files, the usual method of using getByName for layers or history states doesn't seem to work for documents.
var srcDoc = app.Documents.getByName("Gwen_Stefani"); // no success
Is this the correct approach?
A workaround involves looping through the documents array until the required document is found:
getDocumentByName("Gwen_Stefani");
function getDocumentByName(docname)
{
for (var i = 0; i < documents.length; i++)
{
var someDoc = docname.replace(/\..+$/, "");
if (someDoc.toLowerCase() == docname.toLowerCase())
{
alert(someDoc);
app.activeDocument = documents[i];
}
}
}