VBA to log in/pull data from a web page.

ddelgado12

New Member
Joined
Dec 20, 2016
Messages
1
Hi, I am trying to pull data from a web page via VBA (Power Query was painfully slow)... But the data I need requires a login before it will reveal itself. It looks like I am able to fill in my username and password just fine, but I am unsure how to get VBA to actually submit the form. I guess I'm not good at inspecting HTML elements, I'm sure this has an easy answer. Any help is appreciated. Here is what I have:


Code:
Sub process_Web_Data()
    Dim ie As New SHDocVw.InternetExplorer
    With ie
        .Visible = True
        .Navigate "[URL]https://www.muthead.com/login[/URL]"
        While .Busy Or .ReadyState <> 4: DoEvents: Wend
        With .Document
            .getelementbyid("field-username").Value = "username"
            .getelementbyid("field-loginFormPassword").Value = "password"
            .getelementbyid("field-loginFormPassword").submit 'WHAT DO I DO HERE???
        End With
        While .Busy Or .ReadyState <> 4: DoEvents: Wend
        Debug.Print .LocationURL
        '-----------------
        'do all of your other stuff here
        '-----------------
    End With
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You could try submitting the form.
Code:
With .Document
    .getelementbyid("field-username").Value = "username"
    .getelementbyid("field-loginFormPassword").Value = "password"
    forms(0).submit 'WHAT DO I DO HERE???
End With
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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