Open tpanagos opened 9 years ago
Yeah just ran into this issue myself, I think i found a dirty solution.
You can create in internet explorer instance and use it to create the JSON methods / interactions required.
Here is a rough example of the idea:
Sub Example()
Dim ie
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.navigate "about:blank"
Set doc = ie.Document
'Set Script = doc.createElement("script")
Set el = doc.createElement("input")
el.ID = "results"
doc.body.appendChild (el)
doc.parentWindow.execScript ("blue = 45")
doc.parentWindow.execScript ("var getBlue = function(){ return blue;};")
qt = """"
'doc.parentWindow.execScript ("document.all[" & qt & "results" & qt & "].value = getBlue();")
doc.parentWindow.execScript ("document.all[" & qt & "results" & qt & "].value = JSON.stringify({" & qt & "hello" & qt & ":45})")
result = doc.getElementById("results").Value
ie.Quit
End Sub
Is there any chance of a not rough example of a solution too this?
This seemed so promising and now I've wasted half a day on it . :disappointed:
Actually I just realized I'm not even running Office 64 bt, so that's not necessarily what's causing this issues. I am on a 64-bit laptop on Winodows 7 Home Premium, running Excel2016 MSO 32-bit.
CreateObject("scriptcontrol") in SetJson() will fail to create object because that control is a 32-bit only control. Not sure if there is a work-around, but thought people who stumble into it will want to know. https://social.msdn.microsoft.com/Forums/en-US/c6e9c23f-a455-4138-ad86-954d95420739/excel-vba-compatibility-issues-with-microsoft-scriptcontrol-10?forum=isvvba