Highlighted

Indesign simple script works but also gives error message

Community Beginner ,
Nov 18, 2020

Copy link to clipboard

Copied

I have a really basic script that saves the indesign document, then closes it. I have just got a new computer and an updated version of indesign (2021) and now the script does still work, however an error message also pops up afterwards which is annoying because I have to click ok to get rid of it.

 

Does anyone know how to fix it so the error message doesn't happen? Seems like it might be specific to Indesign 2021?

 

Script

main();

function main(){

app.activeDocument.close(SaveOptions.YES);

}

 

Error message

danielw42205661_0-1605740729464.png

 

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

Maybe wrap in a try/catch to work around: 

 

main();

function main(){

try { 
   app.activeDocument.close(SaveOptions.YES);
} catch(e) {}

}
TOPICS
Scripting

Views

67

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Indesign simple script works but also gives error message

Community Beginner ,
Nov 18, 2020

Copy link to clipboard

Copied

I have a really basic script that saves the indesign document, then closes it. I have just got a new computer and an updated version of indesign (2021) and now the script does still work, however an error message also pops up afterwards which is annoying because I have to click ok to get rid of it.

 

Does anyone know how to fix it so the error message doesn't happen? Seems like it might be specific to Indesign 2021?

 

Script

main();

function main(){

app.activeDocument.close(SaveOptions.YES);

}

 

Error message

danielw42205661_0-1605740729464.png

 

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

Maybe wrap in a try/catch to work around: 

 

main();

function main(){

try { 
   app.activeDocument.close(SaveOptions.YES);
} catch(e) {}

}
TOPICS
Scripting

Views

68

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 18, 2020 0
Adobe Community Professional ,
Nov 18, 2020

Copy link to clipboard

Copied

Works fine for me, assuming I have a document open. If there is no document open, it would throw that error. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0
Community Beginner ,
Nov 18, 2020

Copy link to clipboard

Copied

Are you running InDesign 2021?

 

I'm definitely running it on an open document. As mentioned when i run it, it still functions correctly i.e it does save and close the document, but it's still throwing up that message. If you're not using 2021 then it must be specific to that version. I didn't get this error message when using 2019 version. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0
Adobe Community Professional ,
Nov 18, 2020

Copy link to clipboard

Copied

I am on 2021 (16.0); OS is Catalina 10.15.6.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0
Community Beginner ,
Nov 18, 2020

Copy link to clipboard

Copied

Oh ok very strange. I'm on Catalina 10.15.7 so wonder if the last update stuffed it up. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0
Adobe Community Professional ,
Nov 18, 2020

Copy link to clipboard

Copied

Maybe wrap in a try/catch to work around: 

 

main();

function main(){

try { 
   app.activeDocument.close(SaveOptions.YES);
} catch(e) {}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0
Community Beginner ,
Nov 18, 2020

Copy link to clipboard

Copied

Thank you! That fixed it. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2020 0