'Reference : Microsoft Internet Controls / Microsoft HTML Object Library
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub MyGmail()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "https://www.gmail.com"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
'Enter Your Email ID Here
HTMLDoc.all.Email.Value = "youremail@gmail.com"
'Enter Your Password Here
HTMLDoc.all.passwd.Value = "password"
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next MyHTML_Element
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
It enters the emails only but it doesn't enter the password ... Any idea?
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next MyHTML_Element
This is probably difficult. There are two different login pages for Gmail: one in which you have to enter username and password, and another in which you enter only the username and click OK; in the latter you have to provide the password on the next page.
Unless you REALLY need this, I would forget about it.
I have tried once the lines I posted and it worked well. So why worked for once and didn't work later?
Tried to check "Inspect Element" to click "Next" and it worked but for entering the password it didn't work .. although I think it is the same technique