I'm trying to input some words automatically into the "text area" of Google Translate by VBA, and I use "IE.Document.GetElementByID().SetAttribute()" function to input the words. But there are some syntax errors in this expression and I can not find out why.
I have tried the ID of text area by "source"
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://translate.google.com/?hl=zh-TW"
Do Until IE.busy
Loop
Call IE.Document.GetElementByID("source").SetAttribute("value, "Dummy")
I expected the words "Dummy" would automatically input into the text area of Google Translate when I run the codes. The page can be opened, but the "Dummy " didn't show on the text area and shows a "syntax" error with the last line.
This worked for me
Sub dothings()
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "https://translate.google.com"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("source").Value = "Hello world!"
End Sub
This is very useful read http://automatetheweb.net/