Skip to main content
bebarth
Community Expert
Community Expert
July 13, 2020
Question

« closeDoc » and « This file is already open »

  • July 13, 2020
  • 3 replies
  • 1423 views

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.

@+

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
July 13, 2020

This is a bug that has existed in all versions of Acrobat past XI, for a long time now... Adobe doesn't seem interested in solving it, for some reason. It really interferes with the working of many scripts.

bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
July 13, 2020

Thanks try67!

...and no idea about what's happening at the end of each script (or mabe at the beginning) since that works in 2 consecutive scripts?

@+

try67
Community Expert
Community Expert
July 13, 2020

Not quite sure what you mean... but if you're using it in an Action it will automatically close any file it processes, but not other files you create (or open) using a script.

Legend
July 13, 2020

It's an Acrobat bug (files closed aren't really closed) which Adobe don't seem interested in fixing for some reason. So best to avoid this bad habit!

bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
July 13, 2020

OK, thanks.
Just for my understanding, do you know what's happening on at the end of each script since that works with consecutive scripts? I guess a type of variable is reset... isn't it possible to do that with the script?

@+

Bernd Alheit
Community Expert
Community Expert
July 13, 2020

May be that the Action Wizard will close the documents at the end step.

 

Why does you create files with the same name twice?

Bernd Alheit
Community Expert
Community Expert
July 13, 2020

What version of Acrobat Pro?

bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
July 13, 2020

I am working with Acrobat Pro 2019.021 Mac but that was already the same in the previous versions.

@+