skip to Main Content

I need to close all Photoshop documents, be it any number, without saving and without any user prompt. My current code is below for closing the active document only.

psApp = win32com.client.Dispatch("Photoshop.Application")
psApp.Application.ActiveDocument.Close(2) # close file without saving
psApp.Quit()

Photoshops API documentation is terrible, but here’s what I’ve attempted for closing all:

while psApp.documents.length:
    psApp.activeDocument.close()

AttributeError: <unknown>.length

Any help is very much appreciated!

2

Answers


  1. Try this:

    while True:
        try:
            psApp.Application.ActiveDocument.Close(2)
        except:
            break
    psApp.Quit()
    

    I dont have PS, but I can confirm it works with Word!

    Login or Signup to reply.
  2. I can close all active documents with this.

    while psApp.Documents.Count > 0:
        psApp.ActiveDocument.Close(2)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search