Sub LogOn()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
'~~> Paste URL here
ie.Navigate "google.com"
For Each link In ie.Document.Links
If link.innerText = "Sign in" Then
link.Focus
link.Click
End If
Next
'~~> Wait until page is loaded.
While ie.ReadyState < 4
DoEvents
Wend
ie.Document.All("Email").Value = "USERNAME"
ie.Document.All("Passwd").Value = "PASSWORD"
ie.Document.All("signIn").Click
'~~> Wait until page is loaded.
While ie.ReadyState < 4
DoEvents
Wend
End Sub
Sub LogOn()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "google.com"
'~~> Wait until page is loaded.
While ie.ReadyState < 4
DoEvents
Wend
For Each link In ie.Document.Links
Debug.Print link.innerText
If link.innerText = "Sign in" Then
link.Focus
link.Click
Exit For
ElseIf link.innerText = "Sign out" Then
MsgBox "You are already signed in."
Exit Sub
End If
Next
'~~> Wait until page is loaded.
While ie.ReadyState < 4
DoEvents
Wend
On Error GoTo Sidz
Application.Wait Now + TimeValue("00:00:03")
ie.Document.All("Email").Value = "USERNAME"
ie.Document.All("Passwd").Value = "PASSWORD"
ie.Document.All("signIn").Click
'~~> Wait until page is loaded.
While ie.ReadyState < 4
DoEvents
Wend
Exit Sub
Sidz:
MsgBox Err.Description
End Sub
First open a web browser and manually click the SignIn link on top. It will take you to the Sign In page. Copy the URL and paste the URL in the code below and run it :)
Open in new window
Sid