1 Reply Latest reply on Jun 11, 2014 5:08 AM by cwcsdc

    How do I test for the presence of an active open document in Photoshop?

    cwcsdc Level 1

      I’m new to Adobe scripting, and one of my first scripts deals with the activeDocument in Photoshop.

      If there is no activeDocument, I want to display a message and terminate the script.  My efforts

      so far have been met with frustration.  While developing the script in ExtendScript Toolkit,

      I used the  test expression "activeDocument in app", and everything worked as expected. And when I installed the script

      in the Photoshop scripts folder and ran it from Photoshop with a document open, it also worked.

       

      But when I ran the script from Photoshop with no document open, it failed.

       

      Moreover, after that,the script failed when I tried to run it in ESTK.

      I did some testing and found that my test expression, "activeDocument in app"

      was returning true, even though no document was open.

       

      Still in ESTK, I replaced the “app” with ”Application” in the test expression.  That worked when

      I stepped through the script.  But when I tried to run it without stopping, it stopped at the

      test expression, and displayed the error message, “Application is undefined.”

       

      So how do I test for the presence of an open document in Photoshop ??