How do I call a VBA subroutine from Javascript

I have  a PowerPoint VBA add-in that includes a webbrowser control.  In the webbrowser document there is a Javascript function that, when called, should pass information to a subroutine in the VBA.  How can this be done?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You should use the COMAddIns collection (check 'COMAddIn Object' in VBA Help). Create an object and tag it to the COM object as in the code below. Now use appropriate Properties and Methods to return information from it.
Example (from the VBA Help)
The following example returns the object associated with the COM add-in 'msodraa9.ShapeSelect.'

Dim objBaseObject As Object
Set objBaseObject = _

Open in new window

StarDusterIIAuthor Commented:
But the question would be, how do you access that object from the Javascript function?
Not sure if I understood the problem. It would look something like below
When you start Powerpoint application from your script you, probably, do something like below
var thePPApp = new ActiveXObject("Powerpoint.Application");
Then you should be able to use the reference to this object to access any functionality of Powerpoint (switch on the Powerpoint library while coding), which would include objects and their properties and methods.
e.g. thePPapp.Presentations(1).Run
To access VBA project items (like forms) use VBProject object
If it does not work for your browser then you may use a VBScript, which can be called from Javascript and certainly can manipulate VBA routines.
StarDusterIIAuthor Commented:
You're almost there... I created the Javascript in a webbrowser control on a user form.  In the Javascript I have:

var thePPApp = new ActiveXObject("Powerpoint.Application");

My problem was that I had the addQuestion subroutine in the user for and not the module.  Apparently it must be in a module and not a class or user form.  You pass data (ie questionID) with as many parameters as you need in the thePPApp.Run statement.

Thanks for the update.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.