Macro To Log Into Website: Can't Submit Webform

ExcelActuary15

New Member
Joined
Sep 6, 2017
Messages
1
Hi Everyone,

I'm trying to write a macro that will log me into a website (i.e. enter my username and password, then submit the webform). Everything runs perfectly until the macro tries to submit the form...at that point, it just refreshes the login page, rather than redirecting me to the "post-login" page. I'm confident that the username and password that the macro enters are correct, because I can manually press the submit button and it will log me in. This is the code, FYI:

Code:
Sub LogIn()


    Dim ieApp As InternetExplorer
    Dim ieDoc As HTMLDocument
    
    'create a new instance of ie
    Set ieApp = New InternetExplorer
    ieApp.Visible = True
    
    'assume we’re not logged in and just go directly to the login page
    ieApp.Navigate "https://www.nfl.com/login"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    Set ieDoc = ieApp.Document
    
    'fill in the login form
    With ieDoc.forms(1)
        .UserName.Value = "****************@gmail.com"
        .Password.Value = "********"
        .Submit
    End With
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
End Sub

I've also tried the following solutions, which haven't been successful:
.getelementbytagname("Input").Click
.all("Input").click

Any and all help would be appreciated. This is my first foray into html.

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top