I tried seeing what was the problem by making ie.visible(true). It turns out that when I use:
ie.navigate "https://translate.google.com/#" & ilang & "/" & olang & "/" & cell.Value
it doesn't reload the page when it should. For example, refer to the images:
So it enters the new URL in the address bar but doesn't actually navigate to that URL.
Code is here (Subroutine):
Sub Test()
Dim str As String
str = Translate(Range("B3:B7"), "auto", "hi")
End Sub
Actual Code:
'A function called translate
Public Function Translate(r As Range, ilang As String, olang As String) As String
'Declaring all variables
Dim ie As InternetExplorer
Dim y As Integer
Dim ys As String
Dim urmsg As String
Dim result As String
y = 0
Set ie = New InternetExplorer
ie.Visible = True
For Each cell In r
ie.navigate "https://translate.google.com/#" & ilang & "/" & olang & "/" & cell.Value
Do While ie.Busy = True Or ie.readyState <> 4: DoEvents: Loop
y = y + 1
result = ie.document.getElementById("result_box").innerText
Sheets("Sheet1").Range("G" & y).Value = result
Next cell
urmsg = MsgBox(ys & " Translations Executed...", vbOK, "Prompt")
ie.Quit
Translate = " "
End Function
Please tell me what the issue is so that I can solve it. Also, go easy on me if the code is very choppy and has unnecessary lines, I've only studied VBA for a few days.
Thank you.