|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位大师,
下面的代码是咱们论坛里的前辈做的,我修改了一下。
在下面的代码中, 请问要如何添加代码, 才能翻译越南语(附件的最后三行是越南语)。
(我已经自己编写了一个英文,五笔,拼音,越南语一体的输入法,而且不用切换的)
附件如果有不能运行的, 请引用:WINDOWS SCRIPT HOST。。。。。
或者谁认识下面二位老师, 请告知他们的联系方式。
谢谢。
Sub 按钮2_Click() '对suwenkai老师的代码进行了补充,感谢 much 的帮助
Dim pd$, exp$, i%, j%
Set js = CreateObject("scriptcontrol")
js.Language = "jscript"
For i = 2 To Range("A" & 1).End(xlDown).row
If Sheet1.Cells(i, "b") = "" Then
exp = ""
pd = "type=AUTO"
pd = pd & "&i=" & Replace(Replace(Replace(encodeURI(Cells(i, 1).Value), "%", "%C2%"), "%C2%E", "%C3%A"), "%C2%20", " ")
pd = pd & "&doctype=json"
URL = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null"
With CreateObject("msxml2.xmlhttp")
.Open "POST", URL, False
.setrequestHeader "Host", "fanyi.youdao.com"
.setrequestHeader "Connection", "keep-alive"
.setrequestHeader "Content-Length", "137"
.setrequestHeader "Accept", "application/json, text/javascript, */*; q=0.01"
.setrequestHeader "Origin", "http://fanyi.youdao.com"
.setrequestHeader "X-Requested-With", "XMLHttpRequest"
.setrequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
.setrequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
.setrequestHeader "Referer", "http://fanyi.youdao.com/"
.setrequestHeader "Accept-Encoding", "gzip, deflate"
.setrequestHeader "Accept-Language", "zh-CN,zh;q=0.8"
.send (pd)
js.addcode "renahu=" & .responsetext
For j = 1 To js.Eval("renahu.translateResult[0].length")
exp = exp & js.Eval("renahu.translateResult[0][" & j - 1 & "].tgt")
Next
Cells(i, 2) = exp
End With
End If
Next
End Sub
|
|