Using excel macro to run JS code in Acrobat Pro
I have an interesting question. I have an excel sheet that generates a pretty complicated JS script for Acrobat based on a bunch of user inputs in the spreadsheet. I wrote an excel VBA macro that takes this script, opens the desired PDF, opens the JS console, and pastes the code generated code in the console. However, I can't figure out how to actually run this code once it's in the console. Any ideas? Is it possible to make my VB excel macro force Acrobat to execute a JS?
So far this is what I have. My code is in column 1, anywhere from 10-500 lines long which is why I did the If statement in the loop to remove blank cells. How do I make the console execute the code?
Sub Open_Acrobat()
Dim OpenDoc As String
Dim gApp As AcroApp
Dim gPDDoc As Acrobat.AcroPDDoc
Dim jso As Object
OpenDoc = Application.WorksheetFunction.Concat(Cells(2, 3).Value, "\", Cells(2, 2).Value, ".pdf") 'This line generates the filepath of the doc to open
Set gApp = CreateObject("AcroExch.App")
Set gPDDoc = CreateObject("AcroExch.PDDoc")
If gPDDoc.Open(OpenDoc) Then
Set jso = gPDDoc.GetJSObject
jso.console.Show
jso.console.Clear
For i = 1 To 500
If Cells(i, 1).Value = "" Then Exit For
jso.console.println (Cells(i, 1).Value)
Next i
gApp.Show
End If
End Sub
