Photoshop Script - How to check if any document is open?

1.9k Views Asked by At

How do I check if any document is open in Photoshop?

Through Photoshop Script

I've tried activeDocument.length, but it returns that activeDocument is not defined.

I wanted something like this:

if(documents.open === 0){
    alert('NO DOCUMENT');
} else {
    alert('DOCUMENT OPEN');
}
1

There are 1 best solutions below

3
On BEST ANSWER

Close, but no banana. You want

documents.length

See it here:

  if (documents.length == 0)
  {
      alert("No files open to work with, dude!")
  }