These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Executing javascript from VB6.

csearl
Registered: Aug 10 2006
Posts: 28

This is a follow up to my previous question on executing javascript from VB6 (not .NET) defined in a document variable called "jsMain".
 
I've tried quite a few approaches and none seem to do what I need.
 
I even set the .disclosed property to true as well.
 
I've tried the following approaches and many variations:
 
FormVariableName = "$form"
Set objNode = Nothing
Set objNode = jsObject.xfa.resolveNode(FormVariableName)
ReturnValue = objNode.jsMain.myInsertPage(sFormName, lPageNumber)
 
FormVariableName = "$form.#variables[0]"
Set objNode = Nothing
Set objNode = jsObject.xfa.resolveNode(FormVariableName)
ReturnValue = objNode.jsMain.myInsertPage(sFormName, lPageNumber)

ReturnValue = jsObject.xfa.form.jsMain.myInsertPage(sFormName, lPageNumber)
ReturnValue = jsObject.xfa.myInsertPage(sFormName, lPageNumber)
ReturnValue = jsObject.jsMain.myInsertPage(sFormName, lPageNumber)

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Chris, Thanks for sending the form along. We really need a way to post PDFs here.

You have an interesting problem, accessing the xfa structure through the JSO. The JSO exposes the entire Acrobat DOM, however it is limited by the types that can be passed back and forth between VB and JavaScript. There are some obvious incompatibilities here. Incompatibilities that might require special support in the JSO, such as the XFA node objects. VB also has problems with JS names that look like keywords in VB, such as "Form".

I was able to write a VB program that calls your functions by using the Acrobat 8 IAC object. I didn't try with earlier version so I don't know that they don't work, but the 8 object did work with the following code called from a button in the VB6 program. Note that the code resolves the "Variables" node all the way down so that there are no intervening nodes when the function call is made. It would not work otherwise. Note also that the function call is made explicitly with the "Call" statement.

     Set avDoc = gApp.GetActiveDoc()Set gPDDoc = avDoc.GetPDDoc()Set jso = gPDDoc.GetJSObject Dim XVars As ObjectSet XVars = jso.xfa.resolveNode("form.form1.jsMain")Call XVars.myInsertPage("Mm Fred", 42)
Good Luck,

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script