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

Error running Javascript to convert from PDF to XLSX

Community Beginner ,
Jan 11, 2024 Jan 11, 2024

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.

TOPICS
Edit and convert PDFs , General troubleshooting , JavaScript
1.3K
Translate
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
1 ACCEPTED SOLUTION
Community Beginner ,
Jan 15, 2024 Jan 15, 2024
LATEST

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

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

View solution in original post

Translate
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 ,
Jan 11, 2024 Jan 11, 2024

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

"/C/temp/temp.xlsx"

Translate
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 Beginner ,
Jan 11, 2024 Jan 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.

Translate
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 ,
Jan 11, 2024 Jan 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.

 

Translate
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 Beginner ,
Jan 12, 2024 Jan 12, 2024

I do, I have also tested other paths to see if it was a permissions issue.
I tried on my secondary drive with the path "/E/temp.xlsx" and "/E/project/temp.xslx" Still the same error message. I have now also tested on other work machines and the same issue persists so it's not an installation issue.

Translate
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 Beginner ,
Jan 15, 2024 Jan 15, 2024
LATEST

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

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

Translate
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