« closeDoc » and « This file is already open »
To avoid creating temporary files that would then have to be deleted, I usually name them with the final file name and rewrite it.
Maybe it's a bad habit, but I didn’t find any other solutions.
My question is, when I do this in an action or through the console with a single script, I get an error message that tells me that the file is already open.
If I split the action into 2 consecutive scripts, that works fine.
Is there a reason and a way to solve this? I guess that comes from « closeDoc » and the file is supposed to be still open…
Here is an example of a script which works fine in 2 separate scripts, but which gives the message if it is executed in one go:
// Script #1
var newDoc=app.newDoc(612, 792); // Letter
newDoc.saveAs({cPath: this.path.substring(0,this.path.length-4)+"_XXX.pdf"});
newDoc.closeDoc(true);
// Script #2
var newDoc=app.newDoc(612, 1008); // Legal
newDoc.saveAs({cPath: this.path.substring(0,this.path.length-4)+"_XXX.pdf"});…and the message:
RaiseError: Ce fichier est déjà ouvert.
Doc.saveAs:7:Console undefined:Exec
===> Ce fichier est déjà ouvert.
« Ce fichier est déjà ouvert » means « This file is already open »
Thanks in advance for your answers.
@+

