We have a VBA script that runs in Excel 32bit to connect to an API, and convert a JSON string.
However when we try to run the same string on 64bit, the script fails with a “Class not registered” error. This relates to “Script Control” from the Microsoft Script Control 1.0
Private Sub TestJSONParsingWithCallByName()
Dim oScriptEngine As ScriptControl
Set oScriptEngine = New ScriptControl
oScriptEngine.Language = "JScript"
Dim sJsonString As String
sJsonString = "{'key1': 'value1' ,'key2': { 'key3': 'value3' } }"
Dim objJSON As Object
Set objJSON = oScriptEngine.Eval("(" + sJsonString + ")")
Debug.Assert VBA.CallByName(objJSON, "key1", VbGet) = "value1"
Debug.Assert VBA.CallByName(VBA.CallByName(objJSON, "key2", VbGet), "key3", VbGet) = "value3"
End sub
In fact our script was built basis the idea found here: Is There a JSON Parser for VB6 / VBA?
The issue is that we are about to convert our Office system from 32bit to 64bit. And this doesn’t work. we are unable to install any third party software to assist us solve this issue, but surely it must be solvable by using code within the 64bit environment.
Thank you