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

Can I run a JavaScript in Acrobat through Excel VBA?

Community Beginner ,
Aug 17, 2017 Aug 17, 2017

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

TOPICS
Acrobat SDK and JavaScript , Windows
4.8K
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 ,
Aug 17, 2017 Aug 17, 2017

In the Acrobat SDK documentation look for the VB JavaScript bridge.

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 ,
Aug 17, 2017 Aug 17, 2017

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

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

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 ,
Aug 17, 2017 Aug 17, 2017

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?

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 ,
Aug 17, 2017 Aug 17, 2017

I don't think you can use the JS Object in VBA to execute commands via the Console. You need to execute them directly.

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 ,
Aug 17, 2017 Aug 17, 2017

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?

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 ,
Aug 17, 2017 Aug 17, 2017

Not 100% sure, but I doubt it... Why do you need to use the console when you can execute JS code directly, anyway?

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 ,
Aug 17, 2017 Aug 17, 2017

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.

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 ,
Aug 17, 2017 Aug 17, 2017

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>

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 ,
Aug 17, 2017 Aug 17, 2017

How would this be done? For instance if i wanted to run a simple line of code such as:

this.AddWatermark("Filepath" )

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 ,
Aug 17, 2017 Aug 17, 2017
LATEST

I can't really answer that... Maybe ask over here: Acrobat SDK

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