The web page has changed significantly. The object you are trying to read doesn't exist anymore (result_box) or whatever it was.
Try this modified version... I assume it is slower but should work:
I should point out I did very little, most of the credit goes to QHarr on StackOverflow
Public Function getGoogleTranslation(ByRef strSource As String, ByRef strSourceLang As String, ByRef strDestLang As String) As String
Dim IE As Object
Dim t As Date
Const MAX_WAIT_SEC As Long = 5
Set IE = CreateObject("internetexplorer.application")
On Error GoTo getGoogleTranslation_Error
With IE
.Visible = True
.navigate "https://translate.google.com/#view=home&op=translate&sl=" & strSourceLang & "&tl=" & strDestLang
While .Busy Or .readyState < 4: DoEvents: Wend
.document.querySelector("#source").Value = strSource
Dim translation As Object, translationText As String
t = Timer
Do
On Error Resume Next
Set translation = .document.querySelector(".tlid-translation.translation")
translationText = translation.textContent
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While translationText = vbNullString
getGoogleTranslation = translationText
.Quit
End With
On Error GoTo 0
Exit Function
getGoogleTranslation_Error:
If Err.Number = "-2147012894" Then
getGoogleTranslation = "TIimeOut"
Else
getGoogleTranslation = "Error nr: " & Err
Exit Function
End If
End Function
You may want to disable .Visible = True... that will prevent the browser from popping up on the screen.
Error checking may not work as desired anymore either... but I assume you can tweak that if needed.
Bookmarks