简体   繁体   English

使用Excel Json Parser VBA在Excel中键入不匹配(错误13)

[英]Type Mismatch (Error 13) in Excel using Excel Json Parser VBA

Getting Type Mismatch (Error 13) while using Json PArser in Excel MAcro 在Excel MAcro中使用Json PArser时获取类型不匹配(错误13)

Below are the code : 以下是代码:

Sub getJsonValue()
    Dim FSO As New FileSystemObject
    Dim JsonTS As TextStream
    Set JsonTS = FSO.OpenTextFile("C:\Users\Card_Link.json", ForReading)
    JsonText = JsonTS.ReadAll
    JsonTS.Close
    Set Json = ParseJson(JsonText)
    Set JsonRows = Json("rows")
    i = 2
    For Each Item In Json
         Sheet5.Cells(i, 1).Value = Item("name")
        'Sheet5.Cells(i, 2).Value = Item("results")("name")
        'Sheet5.Cells(i, 3).Value = Item("results")("responsecode")
        i = i + 1
    Next
    MsgBox ("complete")
End Sub

Getting error on this statement Sheet5.Cells(i, 1).Value = Item("name") 在此语句上获取错误Sheet5.Cells(i, 1).Value = Item("name")

Can someone please help me to resolve this. 有人可以帮我解决这个问题吗?

Thanks RJ 谢谢RJ

Without having any experience with ParseJson, try one of these: 没有任何ParseJson经验,请尝试以下方法之一:

Sheet5.Cells(i, 1).value = item

Sheet5.Cells(i, 1).value = item(0)

Sheet5.Cells(i, 1).value = item.Name

If still none of these works, try like this: 如果这些方法仍然无效,请尝试以下操作:

For Each item In Json
    Stop
     Sheet5.Cells(i, 1).value = item("name")
    'Sheet5.Cells(i, 2).Value = Item("results")("name")
    'Sheet5.Cells(i, 3).Value = Item("results")("responsecode")
    i = i + 1
Next

On the stop, select item , press Shift + F9 and see what do you have in item . 在站点上,选择item ,按Shift + F9 ,然后查看item有什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM