Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Close active document without saving and without prompt

Explorer ,
Jan 30, 2019 Jan 30, 2019

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

TOPICS
Actions and scripting
6.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 30, 2019 Jan 30, 2019

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)

Translate
Adobe
Community Expert ,
Jan 30, 2019 Jan 30, 2019

Try:

appRef.ActiveDocument.Close(SaveOptions.DONOTSAVECHANGES)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2021 Jan 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2021 Jan 20, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 18, 2021 Sep 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)

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 23, 2025 Jun 23, 2025
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines