View Full Version : "Run-Time Error 91" trying to run Login Code

Jim Clayton
05-29-2019, 07:48 AM
Hello. I've been trying to scrape together a code that will work to auto login to several secure accounts for home budgeting purposes. I'm trying to use the current one to log into my bank (Chase). I'm getting a Run-Time Error 91 thrown at the following line:

HTMLDoc.getElementById("userId").Value = "mylogin"

I continue to get errors at this line. I can't figure out what I'm doing wrong. I hopped on the Chase site, did a right-click on the "login-box" and I think I have the information in there correctly....but I also have no clue what I'm doing so it's possible that I got it wrong. Can someone please look over the below code for me and let me know where I'm going wrong? Thanks for the help.

Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub Chase()
sURL = "https://www.chase.com/"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
'oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
HTMLDoc.getElementById("userId").Value = "mylogin"
HTMLDoc.getElementById("password-input-field").Value = "mypassword"
SendKeys "{Submit}", True
' oBrowser.Refresh ' Refresh If Needed
If Err <> 0 Then
Resume Next
End If
End Sub

Jim Clayton
05-29-2019, 08:36 AM
FYI, Cross-Posted here: https://www.excelforum.com/excel-programming-vba-macros/1277721-login-code-error.html#post5129026