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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,216,084
Messages
6,128,726
Members
449,465
Latest member
TAKLAM

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