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

Button to save/close all open PDF docs [An internal error occurred]

New Here ,
Mar 02, 2020 Mar 02, 2020

Copy link to clipboard

Copied

Hi. I am on Acrobat XI Pro 11.0.23 - it's what our office uses. Have Win10 and Win7 machines and we get the following issue. What we wanted is to achieve a way to:

 

1. Make a button to Close All Open PDF docs. Found a way here - https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm

 

2. I then modified the code so instead of close it performs a Save on all open docs. This I achieved with the code I posted here (user ''So What''😞

https://answers.acrobatusers.com/ViewQuestion.aspx?questionId=293479

 

Several years ago both of these approaches worked flawlessly on a Win7 machine but now on new machines and installs it doesn't. This is how the JavaScrip-based button(s) from the above links look like:

Save All PDFs = Alt+F+F.jpg

 

The problem now on is that when I hit either the Close All or Save All button, Acrobat throws a prompt - 'An internal error occurred' like this one:

An internal error occurredAn internal error occurred

I already tried a plethora of Google suggested solutions having to do with folder permissions and so on. No luck. If anyone has another way of achieving the Save/Close all open PDFs or a way to fix the issue I'm experiencing with my way then pls help. I'll post the code here just in case, but as I said it once worked flawlessly on Win7. Why now it stopped on 7 and 10 I don't know.

 

Code for SaveAllDocsMenuItem.js  :

//////////////////////////////////////////////////////
//
// Save All PDFs Menu Item for Acrobat/Reader
//
// Written by Thom Parker for www.acrobatusers.com
//
// Copyright 2011 by WindJack Solutions, Inc.
//
//////////////////////////////////////////////
// 
//  ** GENERAL INSTALLATION INSTRUCTIONS:
//
//  This Acrobat Automation Script will only work when 
//  placed in one of the Acrobat JavaScript Folders. Execute
//  the following code from the Acrobat JavaScript Console to find
//  the location of the JavaScript folders. 
//
//  To display the Acrobat JavaScript Console use Ctrl+J on 
//  Windows and Command+J on the Mac, does not work properly on newer Mac Books
//
//      app.getPath("user","javascript");
//
//      app.getPath("app","javascript");
//
//  You may place this script file in either one of the folders.
//  However, the "user" folder is shared by both Acrobat and Reader
//  Placing the file in the user folder will make the menu item 
//  availible to both Acrobat and Reader
//

///////
// Business logic for closing documents
//
var DoCloseAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
        app.activeDocs[i].saveAs(app.activeDocs[i].path);
}
   app.endPriv();
});

///////
//  User Interface, places menu item on File menu
//
app.addMenuItem({cName:"Save All PD&Fs", 
                 cParent:"File", 
                 nPos:"Close", 
                 cExec:"DoCloseAllDocs()", 
                 cEnable:"event.rc = app.doc != null"
});


/////////////////////////
// 
//  Variations on the main script.  To use, replace the cExec
//  script in the "addMenuItem" fucntion to use the 
//  given trusted fucntion. 

var DoCloseAllDocs_NoSave = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
        app.activeDocs[i].saveAs(app.activeDocs[i].path);
}
   app.endPriv();
});

//  This variation will not work for documents in Reader
//  that do not have save rights, but it fails in a well
//  behaved manor
var DoCloseAndSaveAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
     {
        oDoc = app.activeDocs[i];
        try{
          oDoc.saveAs(oDoc.path);
        }catch(e){}
        oDoc.closeDoc(false);
     }
   app.endPriv();
});

 

Code for CloseAllDocsMenuItem.js  :

//////////////////////////////////////////////////////
//
// Close All PDFs Menu Item for Acrobat/Reader
//
// Written by Thom Parker for www.acrobatusers.com
//
// Copyright 2011 by WindJack Solutions, Inc.
//
//////////////////////////////////////////////
// 
//  ** GENERAL INSTALLATION INSTRUCTIONS:
//
//  This Acrobat Automation Script will only work when 
//  placed in one of the Acrobat JavaScript Folders. Execute
//  the following code from the Acrobat JavaScript Console to find
//  the location of the JavaScript folders. 
//
//  To display the Acrobat JavaScript Console use Ctrl+J on 
//  Windows and Command+J on the Mac, does not work properly on newer Mac Books
//
//      app.getPath("user","javascript");
//
//      app.getPath("app","javascript");
//
//  You may place this script file in either one of the folders.
//  However, the "user" folder is shared by both Acrobat and Reader
//  Placing the file in the user folder will make the menu item 
//  availible to both Acrobat and Reader
//

///////
// Business logic for closing documents
//
var DoCloseAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
        app.activeDocs[i].closeDoc(false);
   app.endPriv();
});

///////
//  User Interface, places menu item on File menu
//
app.addMenuItem({cName:"Close All PD&Fs", 
                 cParent:"File", 
                 nPos:"Close", 
                 cExec:"DoCloseAllDocs()", 
                 cEnable:"event.rc = app.doc != null"
});


/////////////////////////
// 
//  Variations on the main script.  To use, replace the cExec
//  script in the "addMenuItem" fucntion to use the 
//  given trusted fucntion. 

var DoCloseAllDocs_NoSave = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
        app.activeDocs[i].closeDoc(true);
   app.endPriv();
});

//  This variation will not work for documents in Reader
//  that do not have save rights, but it fails in a well
//  behaved manor
var DoCloseAndSaveAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
     {
        oDoc = app.activeDocs[i];
        try{
          oDoc.saveAs(oDoc.path);
        }catch(e){}
        oDoc.closeDoc(false);
     }
   app.endPriv();
});

 

Looking for help! 10x

TOPICS
Acrobat SDK and JavaScript

Views

5.5K

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
community guidelines

correct answers 1 Correct answer

Explorer , Mar 30, 2020 Mar 30, 2020

So from what I saw and learnt in this thread @Thom_Parker could not be bothered to give basic instructions as to what to do - i.e. give data and give instructions as to what to do with these data. He prolly figured everyone is an IT pro. Well, we ain't. We're mere paying customers. Nevermind, thanks Thom for at least trying. Next time realise that not everyone is in your field of coding or programming and instead of getting angry at ppl try to help them out 🙂 No hard feelings here. One thing fo

...

Votes

Translate

Translate
Community Expert ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

@SoWhat and @1234sa

Thank you for doing the testing in the console. While I don't think you actually got what you were suppose to have done, you did get some traing on using this window.

 

Next, to move forward, run this code in the console window, and post the results. 

 

 

 

var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
     {
        oDoc = app.activeDocs[i];
   console.println("Path:" + oDoc.path);
        oDoc.saveAs(oDoc.path);
        oDoc.closeDoc(false);
     }

 

 

This is the same code as in the function. But the try/catch statements are removed and a console.println statement is inserted that will tell us something about each file before it is processed. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

SoWhat and 1234sa - same person - different accounts and locations. So on Win7 these are the latest updates - As @try67 correctly pointed out for @Thom_Parker 's code 'These two scripts conflict with each other because they both contain a function with the same name (DoCloseAllDocs). However, in one script that functions saves the files and in another it closes them, so that's a big issue. Remove one script and then try it again'. Indeed when only one of the JS files is planted in the JS folder it runs perfectly on Win7. But as soon as both are planted the SaveAll takes precedence rendering CloseAll useless.

 

My question still stands - don't there exist 2 separate functions, one called DoCloseAllDocs and another (I'd assume) DoSaveAllDocs, so then I just mod the SaveAll JS file and flip the DoCloseAllDocs to DoSaveAllDocs?

 

@Thom_Parker I ran the code you provide above, having in advance planted both JS in the folder. That is ofc if by running the code means opening the JS debugger with Ctrl+J, pasting your code in the console window, and right at the bottom pressing Ctrl+Enter. If that's not how you run it then maybe a 1-sentence long explanation wouldn't be bad. This is the result on Win7:

 

SyntaxError: syntax error
1:Console:Exec
undefined

Votes

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
community guidelines
Community Expert ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

In the console press ctrl-a ctrl-enter.

Votes

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
community guidelines
Community Expert ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

You may want to re-watch video on using the console window

Introduction to Scripting in Acrobat

 

Just pressing Ctrl-Enter runs the line the cursor is on. 

To run more than one one you have to select all the lines. 

 

Also, as I'm sure you've already surmised, functions with the same name will overwrite one another. You only need one of the JS files since both define exactly the same functions, i.e. "DoCloseAllDocs" and  "DoCloseAndSaveAllDocs". What you need are more "app.addMenuItem" calls to setup the menu items. But this is not necessarily the issue with the failure. It's just getting your ducks in order.

 

Run the code and we'll see where it's failing. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

Thanks. On Win7, with both JS placed in JS folder, I ran your code the right way and it closed the 2 open pdfs I had and displayed this result immediately after your code:

 

 

Path:/Z/- Desktop/[name of pdf file].pdf
Path:/Z/- Desktop/[name of pdf file].pdf

undefined

 

 

Those are the paths of the PDFs I had opened.

Votes

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
community guidelines
Community Expert ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

So everything worked and there was no problem. 

 

So now, place the "console.println" statement in the function code in the JavaScript file.  Also remove the try/catch statements.

Then test it from the menu items. See if there is an error. The idea is to find a way to consistently create the error conditon, the we look at that. I was hoping it would cause the error when run from the console, but apparently not, so you have do the debug from the code in the JavaScript file.

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

Can you just paste the correct code instead for both CloseAll and SaveAll java scripts?

 

And just a final confirmation. On both W10 and W7 @Thom_Parker's  code runs perfectly as long as only one of the JS files is placed in the JS folder. That much we did know on 7 and now it's also confirmed that it's the same case on 10.

 

And similarly to my last post regarding Win7, now on Win10 when I run

 

var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
     {
        oDoc = app.activeDocs[i];
   console.println("Path:" + oDoc.path);
        oDoc.saveAs(oDoc.path);
        oDoc.closeDoc(false);
     }

 

I get the exact same thing as on 7:

 

Path:/D/- Desktop/3.PDF
Path:/D/- Desktop/2.PDF
Path:/D/- Desktop/1.pdf

undefined

Votes

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
community guidelines
Community Expert ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

So it seems like everything is working and there are no errors? 

Here's all the code for all the functions. Should all be correct. But if not, you now know how to debug 😉

 

 

//////////////////////////////////////////////////////
//
// Save All PDFs Menu Item
// Close All PDFs Menu Item
// Save and Close All PDFs for Acrobat/Reader
//
// Written by Thom Parker, www.windjack.com
//
// Copyright 2020 by WindJack Solutions, Inc.
//
//////////////////////////////////////////////
var DoCloseAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
        app.activeDocs[i].saveAs(app.activeDocs[i].path);
}
   app.endPriv();
});

///////
//  User Interface, places menu item on File menu
//
app.addMenuItem({cName:"Close All PD&Fs", 
                 cParent:"File", 
                 nPos:"Close", 
                 cExec:"DoCloseAllDocs()", 
                 cEnable:"event.rc = app.doc != null"
});


/////////////////////////
// 
//  Variations on the main script.  To use, replace the cExec
//  script in the "addMenuItem" fucntion to use the 
//  given trusted fucntion. 

var DoSaveAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
        app.activeDocs[i].saveAs(app.activeDocs[i].path);
}
   app.endPriv();
});

app.addMenuItem({cName:"Sa&ve All PDFs", 
                 cParent:"File", 
                 nPos:"Close", 
                 cExec:"DoSaveAllDocs()", 
                 cEnable:"event.rc = app.doc != null"
});

//  This variation will not work for documents in Reader
//  that do not have save rights, but it fails in a well
//  behaved manor
var DoCloseAndSaveAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for(var i=len-1;i>=0;i--)
     {
        oDoc = app.activeDocs[i];
        oDoc.saveAs(oDoc.path);
        oDoc.closeDoc(false);
     }
   app.endPriv();
});

app.addMenuItem({cName:"S&ave and Close All PDFs", 
                 cParent:"File", 
                 nPos:"Close", 
                 cExec:"DoCloseAndSaveAllDocs()", 
                 cEnable:"event.rc = app.doc != null"
});

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Beautiful! Thank you! Highly appreciated. 2 small final issues:

 

1. Is it possible when hitting both the 'Close All PDFs' and 'Save and Close All PDFs' to then have the code close Acroat.exe as well?

 

2. Out of the 3 menu buttons, the 'Close All PDFs' does not work. So I debug by running the whole entire new code in console and this is what I got:

 

TypeError: redeclaration of const DoCloseAllDocs
12:Console:Exec
undefined

Votes

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
community guidelines
Community Expert ,
Mar 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Did you delete the other scripts? 

The error message is saying that "DoCloseAllDocs" is already defined. So it must be in another script file. 

 

A script cannot close Acrobat.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

Yep, that was on Win7. I did delete them and left only the new one. Only after deleting and planting the new JS did I run Acrobat.

 

Now with your new JS on Win10:

1) Save and Close all pdfs gives:

An internal error has occurred:

UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:66:Menu S&ave and Close All PDFs:Exec

 

2) Save All PDFs gives:

An internal error has occurred:

UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:44:Menu Sa&ve All PDFs:Exec

 

3) Close All PDFs gives:

An internal error has occurred:

UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:17:Menu Close All PD&Fs:Exec

 

'A script cannot close Acrobat' - thank you for clarifying.

Votes

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
community guidelines
Community Expert ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

Ok, The close function needs to be changed to this:

var DoCloseAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
        app.activeDocs[i].closeDoc(false);
     }
   app.endPriv();
});

 

The Save functions are having a problem with your file paths. These documents were probably opened from an email or some other non-savable location. But to be sure, make this change to the SaveAll function and see what's reported

 

var DoSaveAllDocs = app.trustedFunction(function()
{
   app.beginPriv();
     var len = app.activeDocs.length;
     for (var i=len-1; i>=0; i--) {
       console.println("Path:" + app.activeDocs[i].path);
        app.activeDocs[i].saveAs(app.activeDocs[i].path);
     }
   app.endPriv();
});
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

'The Save functions are having a problem with your file paths. These documents were probably opened from an email or some other non-savable location' - no, the files were locally stored on my drive and that's where I opened them from.

 

Will validate later on Win7 but now on Win10 it all works perfect with one exception - once I make edits in the pdfs and then hit CloseAllPDFs it correctly prompts me - Do you want to save changes to the one file and then to the other. If at that point I hit Cancel cos I changed my mind - then that results in all 3 functions being broken. Again, it only happens when I CancelCloseAllPDFs request. That's the only one one can cancel form anyway. I then have to reopen the docs in order to get the 3 functions to work. So now I debug:

 

- Having hit Cancel on a CloseAllPDFs requests I then run the lates working code (including Thom's latest changes) into console and I get:

 

TypeError: redeclaration of const DoCloseAllDocs
12:Console:Exec
undefined

Votes

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
community guidelines
Explorer ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

OK, still on Win10 I notice the following. If the PDF file name includes a comma, then

 

1) Save All and close gives:
UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:67:Menu S&ave and Close All PDFs:Exec

 

2) SaveAll gives:
UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:45:Menu Sa&ve All PDFs:Exec

 

3) CloseAll works without a problem but if you run it and Cancel the prompt it gives then the exact same issue I posted about in my previous comment happens again.

 

I very much hope you won't tell me that this code only works on PDFs not having a comma in their name [or any other special symbol for that matter - (square) brackets, underscores, etc].

Votes

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
community guidelines
Explorer ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Any comments to my last 2 messages please, @Thom_Parker and @try67? Please do read them together as they're meant to be read so.

Votes

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
community guidelines
Community Expert ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

I've lost track of this conversation. The scripts I've created will do all of that for you.

Votes

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
community guidelines
Explorer ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Thanks but you're scripts are not running either. Read here pls -

Button to save/close all open PDF docs [An internal error occurred]

 

Moreover, can you add the functionality to only perform a SaveAllOpenPDFs without closing them?

Votes

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
community guidelines
Community Expert ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Without knowing the names of the files I can't help you with this.

And yes, it's possible, although I usually charge for customized tools.

Votes

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
community guidelines
Explorer ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

The clear idea is that the names of the files MUST NOT MATTER. With commas, brackets and anything a KB can write. And yes, ok, I understand your financial ideas. If @Thom_Parker is not able to help then we'll have to work something out with you since in 2020 to have BASIC save/close functionality of Acrobat is something you have to pay even extra for ... yes, extra, outside the costs our office already pays to Adobe. Thought this was a free community support forum but sure, I get your financial views too.

Votes

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
community guidelines
Explorer ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

@Thom_Parker as promised, have now validated also in Win7 and the exact same issue persist as descried for Win10 in here:

Button to save/close all open PDF docs [An internal error occurred] 

and here

Button to save/close all open PDF docs [An internal error occurred]

Votes

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
community guidelines
Community Expert ,
Mar 10, 2020 Mar 10, 2020

Copy link to clipboard

Copied

Well, they do matter, because of limitations imposed by Acrobat on how JavaScript can save files.

And as you can see, this is not a trivial tool (although it seems like it should be), and creating it requires time, knowledge and effort.

Votes

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
community guidelines
Explorer ,
Mar 10, 2020 Mar 10, 2020

Copy link to clipboard

Copied

Thanks for the reply and all effort so far. Well, I think we nearly got there with @Thom_Parker after the latest debugging I did so if he responds to the latest updates here we might finally break thru. I'm awaiting as I believe he's busy with other things too.

Votes

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
community guidelines
Community Expert ,
Mar 10, 2020 Mar 10, 2020

Copy link to clipboard

Copied

If you want help, especially free help, you need to provide clear information. 

For first, this error, 

 

TypeError: redeclaration of const DoCloseAllDocs
12:Console:Exec

 

is because you ran code in the console that defines a function that already exists. Don't Do That. The error is meaningless and distract from the issue.

 

Next, this error is also useless:

UnsupportedValueError: Value is unsupported. ===> Parameter cPath.

 

I gave you code to print out the path so we could see what it was. That's the information that you need and were supposed to have provided. 

Let me know when you can do that.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Mar 10, 2020 Mar 10, 2020

Copy link to clipboard

Copied

1. I didn't have to know that

UnsupportedValueError: Value is unsupported. ===> Parameter cPath

is useless information. My only assumption why you say that is because the file name or path to file contain a comma. As I get it this is a limitation of Acrobat XI. Correct me or confirm this once and for all, please - which characters can be present in the file name / path?

 

2. 'I gave you code to print out the path so we could see what it was. That's the information that you need and were supposed to have provided. Let me know when you can do that.' - I did that and did reply back to you here Button to save/close all open PDF docs [An internal error occurred] 

 

At this point you then asked me to change the var DoCloseAllDocs and var DoSaveAllDocs in your latest code (which unites all 3 functions). I did that and reported back on the results. You never replied after that.

Votes

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
community guidelines
Community Expert ,
Mar 10, 2020 Mar 10, 2020

Copy link to clipboard

Copied

This line of code prints the files path to the console window

console.println("Path:" + app.activeDocs[i].path);

 

This is what I was looking for.  I don't see the results of an actual file path in this thread. 

 

However, I've been using file names with brackets and commas for a while. Never had any problems with punctuation except for the slashes, which have special meaning.  It's possible that your specific characters are unicode characters that are problematic, but I doubt that as well. The problem could also stem from the OS. Of course I wouldn't know about any of these things because you have shared the actual path and file name.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines