I've been trying to translate a word passed through the transFunc function and display the translated word in a MsgBox. When I try to run my code, I get an error saying Object doesn't support this property or method. I know it is messing up at the "cleanData = " line, but I can't figure out why. I've been trying for days now, so any help is greatly appreciated. Thank you so much!!!
Public Sub transFunc(Optional Word As String)
Dim IE As Object
Dim i As Long
Dim inputString As String
Dim outputString As String
Dim textToConvert As String
Dim resultData As String
Dim cleanData As Variant
Dim Url As String
Dim j As Integer
Set IE = CreateObject("InternetExplorer.application")
inputString = "auto"
outputString = "es"
textToConvert = Word
IE.Visible = True
Url = "https://translate.google.com/?sl=" & inputString & "&tl=" & outputString & "&text=" &
textToConvert & "&op=translate"
IE.navigate Url
Do Until IE.readyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:5"))
Do Until IE.readyState = 4
DoEvents
Loop
replaceInput = IE.document.getElementById("result_box").innerHTML
splitInput = Replace(replaceInput, "</SPAN>", "")
cleanData = Split(splitInput, "<")
For j = LBound(cleanData) To UBound(cleanData)
resultData = resultData & Right(cleanData(j), Len(cleanData(j)) - InStr(cleanData(j), ">"))
Next j
MsgBox (resultData)
IE.Quit
End Sub