I wish to manipulate Excel spreadsheets using macros in JavaScript rather than the default VBA. I can execute JavaScript code using the following VBA code
'JavaScript to execute
Dim b As String
b = "function meaningOfLife(a,b) {return 42;}"
'VBA tool to run it
Dim o As New ScriptControl
o.Language = "JScript"
o.AddCode b
MsgBox o.Run("meaningOfLife", 0, 1)
This enables me to execute arbitrary JavaScript, however I do not have access to the Excel spreadsheet from within the JavaScript environment. Is there any way I can set and get worksheet values in the active worksheet from within JavaScript?
It depends what sort of "Excel programming" you want to do.
If you want to manipulate Excel files, you can do so via COM automation, or even ODBC to some degree, using JavaScript running under the Windows scripting environment.
But if you want to have your code running within an active Excel session doing things the visitor will see, you have fewer options.
See this question I posted a few years back when I had some JavaScript I wanted to run within Excel and didn't have the budget to convert to VBA: