Those of you that read this blog, and the ramblings site, will know that the topic content is about equally split between VBA and javaScript.
Until today, I had no idea that there was a scripting object that could be used from VBA, but would allow you to write your code in JScript. The ScriptControl object allows you to do that.
Consider this (you’ll need to add a reference to scriptControl v1.0 in the VBE)
12345678 Public Sub x()Dim o As New ScriptControlo.Language = "JScript"With o.AddCode "function x(a,b) {return 'the answer is:' +(a+b);}"Debug.Print .Run("x", 1, 2)End WithEnd Sub
the answer is:3
… you will see more about this in future posts as I dig into how far this can be pushed.
Sadly I don't have this reference available on my machine…?
Maybe here..
http://www.microsoft.com/download/en/details.aspx?id=1949