vba login to internet

wxue

New Member
Joined
May 13, 2008
Messages
35
how can I login to a website using vba. I googled many examples but still failed. any one can help me? Thanks
 
This code will do the login part but obviously isn't fully tested because I've no username or password.

Rich (BB code):
Option Explicit

Sub LogIn()
Dim IE As Object
Dim doc As Object
Dim frm As Object
Dim username As Object
Dim pwd As Object
Dim strURL As String
Dim strUserName As String
Dim strPwd As String

    strURL = "https://www.theice.com/homepage.jhtml?loginApp=ICE"
    
    strUserName = "YourUserName"
    strPwd = "YourPasssword"
    
    Set IE = CreateObject("InternetExplorer.Application")
    
    IE.Visible = True
    
    IE.navigate strURL

    Do Until IE.ReadyState = 4
        DoEvents
    Loop
    Set doc = IE.Document
    
    Set frm = doc.getElementById("loginForm")
    
    Set username = doc.getElementById("j_username")
    
    Set pwd = doc.getElementById("j_password")
    
    username.Value = strUserName
    
    pwd.Value = strPwd
    
    frm.submit
    
    Set IE = Nothing
    
End Sub
There's also another problem - there appears to be some sort of pop-up or add-in which I had to allow so the form would be submitted.
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
@Daffy - 100% correct. To further elaborate, the file access is a spreadsheet, which I will then save down in a specified folder (already have the code in place for this), at which point the process is handed over to another macro that runs an analysis on the file in question.

@Norie - tried the macro, it worked in that it opened the site and entered the username & password. No luck on the dropdown selection, or in proceeding to the next page and saving down the file :(

Thanks again for all your help guys, it means a lot!
 
Upvote 0
What dropdown?

Is that on the page after you login?

Or do you mean the one above the username?

What is it you want to select?

By the way, it really would be an idea to start a new thread for this.

This one originally started 3 years ago.

It's too much hassle going back through all the posts to find when you made your first post in it.

That could even be why I missed the combobox bit, which I can now see, both your post about it and where it is on the page.:)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,225,204
Messages
6,183,574
Members
453,170
Latest member
sameer98

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