我正在尝试通过触发以下代码使用自动检测将其他语言转换为英语。
Sub transalte_using_vba()
Dim ie As Object, i As Long
Dim inputstring As String, outputstring As String, text_to_convert As String, result_data As String, CLEAN_DATA
Set ie = CreateObject("InternetExplorer.application")
inputstring = "auto"
outputstring = "en"
text_to_convert = Sheet3.Range("A2")
'open website
ie.Visible = False
ie.navigate "http://translate.google.com/#" & inputstring & "/" & outputstring & "/" & text_to_convert
Do Until ie.ReadyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:5"))
Do Until ie.ReadyState = 4
DoEvents
Loop
CLEAN_DATA = Split(Application.WorksheetFunction.Substitute(ie.Document.getElementById("result_box").innerHTML, "</SPAN>", ""), "<")
For i = LBound(CLEAN_DATA) To UBound(CLEAN_DATA)
result_data = result_data & Right(CLEAN_DATA(i), Len(CLEAN_DATA(i)) - InStr(CLEAN_DATA(i), ">"))
Next
Sheet3.Range("B2") = result_data
ie.Quit
MsgBox "Done", vbOKOnly
End Sub
但是我面临运行时错误 424 object required in lineCLEAN_DATA = Split(Application.WorksheetFunction.Substitute(ie.Document.getElementById("result_box").innerHTML, "</SPAN>", ""), "<")
代码有什么问题?
这段代码工作有点慢..因为我需要处理超过 70K 的批量数据,有什么快速的方法可以做到这一点吗?
在我的系统中,我将 google chrome 作为默认浏览器,我们可以使用它进行翻译,这可能有助于更快地运行脚本吗?