通过此链接[Excel Function To Convert English Names To Arabic]我尝试调整以下代码以将名称从阿拉伯语翻译为英语
Function Translate_To_English (Rng As Range) As String
' Tools Refrence Select Microsoft internet Control
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")
' TO CHOOSE INPUT LANGUAGE
inputstring = "ar"
' TO CHOOSE OUTPUT LANGUAGE
outputstring = "en"
text_to_convert = Rng.Text
'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 j = LBound(CLEAN_DATA) To UBound(CLEAN_DATA)
result_data = result_data & Right(CLEAN_DATA(j), Len(CLEAN_DATA(j)) - InStr(CLEAN_DATA(j), ">"))
Next
IE.Quit
Translate_To_English = result_data
End Function`
但它没有奏效并说错误
请帮忙吗?
答案 0 :(得分:0)
我刚刚获得了将Google翻译与Google表格相关联的代码。
=GOOGLETRANSLATE(C4, "ar", "en")
它有效,但它有时会给出名称的含义,结果变得如此有趣。
例如:
Ali Saleh的耐心عليصالحصبر
阿里·侯赛因很无聊عليحسينغثيث现在的年龄عمرحاضرعمر