Skip to main content
grendizerus
Known Participant
Jan 30, 2019 2:03 PM UTC
Answered

Close active document without saving and without prompt

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

Chuck Uebele
Chuck UebeleCorrect answer
Community Expert
Jan 30, 2019 5:23 PM UTC

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)

5 replies

Community Expert
Jun 23, 2025 9:50 AM UTC

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 )

Translate
HoodEvent
Participant
Sep 18, 2021 1:52 PM UTC

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)

 

Translate
jonathanw96483303
Participant
Jan 20, 2021 9:16 PM UTC

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)

Translate
Stephen Marsh
Community Expert
Community Expert
Jan 21, 2021 4:29 AM UTC

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

Translate
Chuck Uebele
Community Expert
Chuck UebeleCommunity ExpertCorrect answer
Community Expert
Jan 30, 2019 5:23 PM UTC

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)

Translate