Skip to main content
grendizerus
Known Participant
January 30, 2019
Answered

Close active document without saving and without prompt

  • January 30, 2019
  • 4 replies
  • 6371 views

Hello I am trying to close an open document without saving and without a prompt asking if I want to save

here is my VBS code:

Set appRef = CreateObject("Photoshop.Application")

appRef.ActiveDocument.Close(psDoNotSaveChanges)

Well it does not work, a prompte still pops up and asks me if I want to save or not...

HELP?

Thanks

David

Correct answer Chuck Uebele

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)

4 replies

Community Expert
June 23, 2025

Hi together,

after some years I came back to PhotoShop DOM scripting. And obviously something ( a lot maybe ? ) has changed perhaps.

I used the old DOM Documentation from a PhotoShop version about 10 years back, that gave me the wrong Enumerator regarding the close() method:

https://www.indesignjs.de/extendscriptAPI/photoshop2015.5/#Document.html#d1e47935__d1e48452

https://www.indesignjs.de/extendscriptAPI/photoshop2015.5/#SaveOptionsType.html#d1e26997

 

Old DOM Documentation said: SaveOptionsType.DONOTSAVECHANGES.

I finally found the right one in a more recent PhotoShop script on the web with: SaveOptions.DONOTSAVECHANGES

 

To my surprise PhotoShop 2025 did do no error message when I used the wrong enumerator. It just did nothing.

PhotoShop 2023 at least gave me a clue with the error message ( translated from German )  : "Error 2 SaveOptionsType is undefined".

 

What worked in PhotoShop 2023 and 2025 was:

app.activeDocument.close( SaveOptions.DONOTSAVECHANGES ) ;

 

Two questions remain:

[1] Is there a current DOM documentation for ExtendScript out there for PhotoShop 2025?

[2] Why did PhotoShop 2025 issue no error message on the same script?

app.displayDialogs was set to DialogModes.ERROR I finally learned.

Why? I have no idea. Is this the new default perhaps?

 

Now that I changed app.displayDialogs to DialogModes.ALL, the error message is coming up with PhotoShop 2025 just like PhotoShop 2023 did.

 

Thanks,
Uwe Laubender
( Adobe Community Expert )

HoodEvent
Participant
September 18, 2021

The scripting reference has these constant values for PsSaveOptions as

1 (psSaveChanges)

2 (psDoNotSaveChanges)

3 (PsPromptToSaveChanges)

 

I code in Python and this worked for me:

 

docRef.close(2)

 

jonathanw96483303
Participant
January 20, 2021

Not sure why, but this answer didn't work for me.

Instead, I used below:

 

app.activeDocument.close(SaveOptions.no);

 

(This was for indesign 2019)

Stephen Marsh
Community Expert
Community Expert
January 21, 2021

You shouldn't expect different Adobe apps to share the exact same code.

Chuck Uebele
Community Expert
Chuck UebeleCommunity ExpertCorrect answer
Community Expert
January 30, 2019

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)