I have an Acrobat .pdf document which includes a Javascript global variable. I am trying to get code in VBA that will reference the value of this global from Acrobat, but I can't quite figure out the necessary syntax to do so. I assume that this is a trivially simple question, but nonetheless it has me stumped.
Basically, in my Acrobat/.pdf document, I have some very simple Javascript that defines:
global.ReturnString = "Arbitrary String";
and then I have another very simple button that displays that return string as an app alert:
app.alert(global.ReturnString);
All I want to do is to be able to reproduce this extremely simple functionality via an Excel message box. In other words I just want to write some working VBA code that will successfully execute this in Excel:
MsgBox (SomeSortOfPointerToAcrobat.Global.ReturnString)
So far I haven't been able to get this to work. I've tried using GetJSObject as the construct to pass info between Acrobat and Excel (VBA code below). I am currently opening the .pdf file in an Excel userform at the time that I am trying to reference the JavaScript global variable in Excel VBA:
Dim gAPP As Acrobat.CAcroApp
Dim gPDDOC As Acrobat.CAcroPDDoc
Dim jso As Object
Set gAPP = CreateObject("AcroExch.App")
Set gPDDOC = CreateObject("AcroExch.PDDoc")
If gPDDOC.Open("C:\path\testdoc.pdf") Then
Set jso= gPDDOC.GetJSObject
MsgBox (jso.Global.ReturnString)
End If
But this always leads to run-time error '438': Object doesn't support this property or method.
I have the Adobe Acrobat 10.0 Type Library added to my VBA project.
Any suggestions?
Again, I apologize for what I assume is a very trivial question. I'm happy to clarify as needed for any needed details that I've left out of this description of the question.
(Marking as answered so that this no longer shows as an open question)
ANSWER: Code was, in fact, correct as-is in the original question.