I’m trying to access current opened document in script, but it’s undefined. But i have opened document in Photoshop. Should i initialize it somehow?
Here is my code
function ProcessDocumentWithoutXML()
{
g_rootDoc = app.activeDocument;
g_progBar = new ProgressBar();
if (app.activeDocument != null)
{
ProcessLayersWithoutXML(g_rootDoc);
alert("Done!");
} else {
alert("Missing active document");
}
}
ProcessDocumentWithoutXML();
3
Answers
In order for it to work
needs to be outside the function (unless you pass in the source document to that function).
Amended code:
If you are running photoshop in one window and running your code in ExtendedScript in other window you need to add the first line
“#target photoshop”
(without double marks) on your js script.
In my case the problem was caused by missed variable name: