|
楼主 |
发表于 2016-10-4 21:34
|
显示全部楼层
- Sub GetData1()
- Dim w$, url$, strJSON$, strFunc$, XML, objSC, objJSON, v
- w = "work"
- url = "http://fanyi.baidu.com/v2transapi"
- Set XML = CreateObject("Microsoft.XMLHTTP")
- With XML
- .Open "POST", url, False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send "from=en&to=zh&query=" & w & "&simple_means_flag=3"
- While .readyState <> 4
- DoEvents
- Wend
- ' CopyToClipbox (.responseText)
- Set objSC = CreateObject("scriptcontrol")
- objSC.Language = "jscript"
- strJSON = .responseText
- strFunc = "function getjson(s) { return eval('(' + s + ')'); }"
- objSC.addcode strFunc
- Set objJSON = objSC.CodeObject.getjson(strJSON)
- ' Cells(1, 1) = objJSON.dict_result.simple_means.from
- Cells(1, 1) = objJSON.dict_result.simple_means.symbols[0].parts[0].part '报错
- End With
- End Sub
复制代码
Cells(1, 1) = objJSON.dict_result.simple_means.symbols[0].parts[0].part 这个句子有错吗? |
|