Copy link to clipboard
Copied
Hello,
I have a couple of questions about app.activeDocument.close(SaveOptions.yes);
just want to know if there's any way to prevent the two issues below from happening or if there is a another method to access the Save As dialog window
1. In the dialog window if the cancel button is selected the document still closes.
2. If the cancel button is selected you'll recieve a javascript error.
Thanks in advance!
Mike

Hi Mike,
Technically you are not 'avoiding' the error, you are just handling it by doing the try catch, it means the error is thrown but the 'catch' part of your code is dealing with it.
Although the code you have posted doesn't make much sense as there are far too many {}
// a standard try....catch would look like this.
try
{
app.activeDocument.save();
exit();
}
catch (e)
{
}
Regards
Malcolm
Copy link to clipboard
Copied
Hi Mike,
Has the document you are closing already been saved? (if not this will through an error as it can't save a file without a path, and therefore a file has to have been saved once for your code to work)
Regards
Malcolm
Copy link to clipboard
Copied
Hi Malcolm,
No the document has not been saved, it's opened from a template through my code.
the method below works giving me access to the Save As dialog and avoids the javascript error If the cancel button is selected.
try {
app.activeDocument.save(); {
} {
exit();
}} catch (e) {
}
Thanks,
Mike
Copy link to clipboard
Copied
Hi Mike,
Technically you are not 'avoiding' the error, you are just handling it by doing the try catch, it means the error is thrown but the 'catch' part of your code is dealing with it.
Although the code you have posted doesn't make much sense as there are far too many {}
// a standard try....catch would look like this.
try
{
app.activeDocument.save();
exit();
}
catch (e)
{
}
Regards
Malcolm
Copy link to clipboard
Copied
Hi Malcolm,
You're correct, I should have stated that the error is being handled by the try catch not "avoided". The extra {} came from me grabbed the try catch in from somewhere else in my code that contained a "if" and "else" and I neglected to properly clean it up.
Thanks,
Mike
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more