knitin28289
New Member
- Joined
- Dec 27, 2017
- Messages
- 2
Hi,
This below code is helpful to get the data from json. but I am getting error at line "Set MyList = RetVal.Data" . The error is 'Object doesn't support this property or method'.
Note : I am able to extract all data from URL into object Retval when I can see all the details in Watches.
Please help me in this. Do I need to add any references for this or need to create a specific object for this.
Code :
Sub Test5()
Dim objHTTP As Object
Dim MyScript As Object
Dim i As Long
Dim myData As Object
Set MyScript = CreateObject("MSScriptControl.ScriptControl")
MyScript.Language = "JScript"
URL = "https://min-api.cryptocompare.com/data/histominute?fsym=BTC&tsym=USD&limit=60&aggregate=3&e=CCCAGG"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", URL, False
objHTTP.send
Set RetVal = MyScript.Eval("(" + objHTTP.responsetext + ")")
objHTTP.abort
i = 2
Set MyList = RetVal.Data
x = 0
For Each myData In MyList
x = x + 1
If x = 1 Then 'Get values from the second data
Cells(i, 1).Value = myData.volumefrom
Cells(i, 2).Value = myData.volumeto
i = i + 1
Exit For
End If
Next
Set MyList = Nothing
Set objHTTP = Nothing
Set MyScript = Nothing
End Sub
This below code is helpful to get the data from json. but I am getting error at line "Set MyList = RetVal.Data" . The error is 'Object doesn't support this property or method'.
Note : I am able to extract all data from URL into object Retval when I can see all the details in Watches.
Please help me in this. Do I need to add any references for this or need to create a specific object for this.
Code :
Sub Test5()
Dim objHTTP As Object
Dim MyScript As Object
Dim i As Long
Dim myData As Object
Set MyScript = CreateObject("MSScriptControl.ScriptControl")
MyScript.Language = "JScript"
URL = "https://min-api.cryptocompare.com/data/histominute?fsym=BTC&tsym=USD&limit=60&aggregate=3&e=CCCAGG"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", URL, False
objHTTP.send
Set RetVal = MyScript.Eval("(" + objHTTP.responsetext + ")")
objHTTP.abort
i = 2
Set MyList = RetVal.Data
x = 0
For Each myData In MyList
x = x + 1
If x = 1 Then 'Get values from the second data
Cells(i, 1).Value = myData.volumefrom
Cells(i, 2).Value = myData.volumeto
i = i + 1
Exit For
End If
Next
Set MyList = Nothing
Set objHTTP = Nothing
Set MyScript = Nothing
End Sub