GMail recently underwent some changes and no longer supports the one-page login format, and instead has switched to a page-by-page step login (at least that's what I call it) when logging in. I'm testing my code out in Excel VBA which inputs the email address (or user) and to click the "Next" button to advance to the password page, then repeats the process with the password page. The references in my Excel 2010 program which are checked off are:
- Visual Basic for Applications
- Microsoft Excel 14.0 Object Library
- Microsoft Office 14.0 Object Library
- OLE Automation
- Microsoft Forms 2.0 Library
- Microsoft Internet Controls
- Microsoft HTML Object Library
The email field is filled in, but after that, the compiler throws the runtime error 438 and won't advance. I know the answer is probably right under my nose, but I can't seem to figure out what's going on. I have tried getting the HTML ID of the "Next" button, but to no avail. I'm just stuck.
Option Explicit
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub MyGmail()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
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
HTMLDoc.all.Email.Value = "[email protected]"
HTMLDoc.all.passwd.Value = "xxxxxxxxxxxxxx"
For Each MyHTML_Element In HTMLDoc.getElementsByID("Email")
If MyHTML_Element.ID = "next" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub