Skip to main content
Participant
January 13, 2025
Question

Open excel file with a click of a button in PDF

  • January 13, 2025
  • 2 replies
  • 283 views

Hi, I have created a button, to trigger it to run a javascript code, to launch excel file.

My java code as below:

 

var filePath = "file:///C:/Path/To/Your/File.xlsx"; 
app.launchURL(filePath, true);

 

The problem is, it wont open the excel file.

Is my code is correct? Anything that I miss out?

 

Thanks in advance

2 replies

try67
Community Expert
Community Expert
January 13, 2025

To be able to do it you must attach the Excel file to the PDF, then use a script to open it.

Thom Parker
Community Expert
Community Expert
January 13, 2025

No, it won't work. Did you look in the Console Window (Ctrl-J) to see the reported error?

 

Acrobat is sandboxed. Meaning that scripts in a PDF operate only in the PDF/Acrobat enviroment, NO touching things on the users local system, unless specific security measures are taken.  And even then, there are limitations in the API. 

Read this:

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm

 

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