I used the below Excel VBA function for Google Translate, and it worked perfectly in October 2018. But this week, I tried to use it, and I get the run time error 424 (object required) at the following line:
CLEAN_DATA = Split(Application.WorksheetFunction.Substitute(IE.Document.getElementById("result_box").innerHTML, "</SPAN>", ""), "<")
Do you know what has changed in the past month to result in this code not working anymore? I think the ID for Google Translate may have changed, but I do not know how to check and pull the correct ID for the translation results.
-------------
Function translate_using_vba(str) As String
' Tools Refrence Select Microsoft internet Control
Dim IE As Object, i As Long
Dim j As Integer
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 = "auto"
' TO CHOOSE OUTPUT LANGUAGE
outputstring = "en"
text_to_convert = str
'open website
IE.Visible = False
IE.navigate "...I had to remove the link to make the post go through ...
Do Until IE.ReadyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:3"))
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_using_vba = result_data
End Function
Bookmarks