Skip to main content
New Participant
January 11, 2024
Answered

Error running Javascript to convert from PDF to XLSX

  • January 11, 2024
  • 1 reply
  • 1846 views

While running the code: saveAs("C:\temp\temp.xlsx", "com.adobe.acrobat.xlsx") it will start converting before the error: "The specified file could not be written to. It may be in use" pops up and the conversion fails. So I decided to test that theory using the Windows utility File Locksmith, the only program accessing the PDF is Acrobat DC.

I also tested just converting through Export menu and it works just fine, this error only occurs when using JavaScript. How can I bypass this issue as I am looking to automate this process using VBA after confirming the javascript is working.

This topic has been closed for replies.
Correct answer Ashwood Forest

It's the same path syntax for all platforms.

The code works fine for me. Do you actually have a folder called "temp" under the C drive? Because the script can't create it for you.

 


Found the solution.
Under Preferences -> Security (Enhanced) -> Disable Protected Mode at startup

After changing that setting and restarting the code was executing flawlessly.

1 reply

try67
Braniac
January 11, 2024

The correct file-path syntax you need to use is this:

"/C/temp/temp.xlsx"

New Participant
January 11, 2024

Thanks for the fast response,

On a Windows system you would use a more Unix like path?
Testing with the path set as "/C/temp/temp.xlsx" still produces the same error unfortunately.

try67
Braniac
January 11, 2024

It's the same path syntax for all platforms.

The code works fine for me. Do you actually have a folder called "temp" under the C drive? Because the script can't create it for you.