Copy link to clipboard
Copied
Hello,
Can someone please redirect me to an example or documentation to call a VBA Script within Javascript. I would like to set up such that when you press a button on the Acrobat pdf file it runs the VBA code.
I would like to send a string of data from a text field in Acrobat into my VBA code and then return the result (text string) of my vba code back into acrobat pro.
Please advise!
Again... you can't "send" anything "over to" the VBA application. The VBA application needs to reach into Acrobat and get it then push the results into Acrobat as well. Check out the documentation for using the JavaScript Object from VBA. That will get you started.
Copy link to clipboard
Copied
You cannot call a VBA script from JavaScript. Acrobat's JavaScript runs in a "sand box" and there is almost no way to interact with something that is outside of Acrobat.
Copy link to clipboard
Copied
Karl is correct. However, there are tricks you can play.
You can use VBA to query Acrobat for the existence of an object (a variable or field value) at a fairly frequent interval, every quarter second for example. Pressing the button in Acrobat would create the object the VBA code is looking for and set it's value. At the next interval, your VBA code sees the object, gets the value, then runs whatever other code you want and pushes the result back to the PDF and deletes the object.
You'd need to have Acrobat and the application running the VBA running at the same time.
Copy link to clipboard
Copied
Thanks for your reply Joel.
I have created the string in Acrobat that I would like to send over to VBA. How would i send this string to VBA? Similarly in VBA how would i send the result back into Acrobat?
Can you please direct me to some documentation.
Thanks
Copy link to clipboard
Copied
Again... you can't "send" anything "over to" the VBA application. The VBA application needs to reach into Acrobat and get it then push the results into Acrobat as well. Check out the documentation for using the JavaScript Object from VBA. That will get you started.
Copy link to clipboard
Copied
Joel,
Thanks for directing me the right way. I also found this article (Reading And Modifying PDF Form Fields with VBA - KHKonsulting LLC ) which was great help .
What worked for me was creating a VB application that reads a field in an acrobat form and then sends a calculated value back to acrobat.