Can I run a JavaScript in Acrobat through Excel VBA?
Copy link to clipboard
Copied
Here's the quick version of my question. I have an excel spreadsheet that writes a JavaScript script in column A of my spreadsheet based on user inputs. I want to be able to run a vba macro in excel that opens acrobat and runs that javascript. I've already figured out how to open Acrobat using VBA in excel, but have not figured out how to open the JS debugger, paste my code in, and run it.
In summary: How can I open the acrobat debugger and run my code using an excel VBA macro?
Any help would be much appreciated.
Thanks
Copy link to clipboard
Copied
In the Acrobat SDK documentation look for the VB JavaScript bridge.
Copy link to clipboard
Copied
Here's a link to the reference you need. It's an old doc, but nothing has changed.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/VBJavaScript.pdf
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
For some reason in this line below that I got from that link it won't let me use a string variable as the file path.
If gPDDoc.Open("c:\adobe.pdf") Then
I want to use a variable instead of typing out the file path. However, when I use a variable declared as String it doesn't work. Example below:
Dim OpenDoc As String
OpenDoc = "c:\adobe.pdf"
If gPDDoc.Open(OpenDoc) Then
The entire code works if I type out the file path, but does not work if I use the string variable to replace my file path.
What's the difference between "If gPDDoc.Open(OpenDoc) Then" and "If gPDDoc.Open("c:\adobe.pdf") Then" ?
Also, what's the command to execute the console once all of my script is in there?
Copy link to clipboard
Copied
I don't think you can use the JS Object in VBA to execute commands via the Console. You need to execute them directly.
Copy link to clipboard
Copied
I've now gotten the entire script to do what I want except one thing..... execute the script once it's in the console. Try67 you're saying this is not possible?
Copy link to clipboard
Copied
Not 100% sure, but I doubt it... Why do you need to use the console when you can execute JS code directly, anyway?
Copy link to clipboard
Copied
I made a really complicated excel spreadsheet that generates a pretty complicated JS based on user inputs. The idea was to have the user copy and paste that JS into acrobat console and run it once they were done applying their settings in the excel sheet. I've now written an excel vba macro that copies that generated code into the acrobat JS console but I just need the code to run it. It's not a huge deal if there is no way to run the code, as running it manually takes less than five seconds.
Copy link to clipboard
Copied
Just have your JS Object run the same commands that you want the user to
run...
On Thu, Aug 17, 2017 at 10:56 PM, shallberg7 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
How would this be done? For instance if i wanted to run a simple line of code such as:
this.AddWatermark("Filepath" )
Copy link to clipboard
Copied
I can't really answer that... Maybe ask over here: Acrobat SDK

