VBA to log into website

Rowanmk

New Member
Joined
Feb 28, 2012
Messages
5
Hi All,
I am a complete novice but trying to do the following in 2 steps.
I have a dashboard in an excel document that uses data from a .csv download from a site. There is a direct download URL that requires me to enter my username and password before it starts downloading. I then want the macro to fetch the latest download in a specified download folder and past it into a specific table each time I hit refresh.
So I see this happening in two phases:
1) A macro to go to the URL, enter a username and password and hit submit. This will download the required file.
2) A macro to find the latest download and import the date into a specified table.
Is anyone able to assist me with this? I am unsure how best to get support from you excel geniuses!
Regards
Rowan
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Here's some code that will take you to a webpage (this one).

You need to go to your page and view the html code (press F12 in internet explorer, and press the search button and select the login, password and submit boxes) to see how to identify those items and interact with them.

In the below i've shown examples of what to do if they have id's.

Code:
Sub gotoURL()


Dim appIE As Object

Set appIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
    
        With appIE
            .Visible = True
            .Navigate "https://www.mrexcel.com/forum/excel-questions/1075064-vba-log-into-website.html"
        
            While appIE.Busy Or appIE.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
    
            Set login = appIE.Document.getElementById("username")
            login.Value = "myusername"
            
            Set pword = appIE.Document.getElementById("password")
            pword.Value = "mypword"
    
            Set clicklogin = appIE.Document.getElementById("btnlogin")
            clicklogin.Click
    
        End With
        appIE.Quit
        
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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