logon to webpage with username and password required

jek40

Active Member
Joined
Jan 17, 2005
Messages
317
I found this code to log into a website. it seems to work fine, however

I need to modify it to enter a user name and password to logon to page one of the site and then continue to page 2 once the user name and password is entered.

Thanks for any help

John

Code:
Dim strProductTable

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "http://www.xpresswayplus.com/webapp/magec/servlet/Production"
         Do Until .readyState = 4
             DoEvents
         Loop
         Set myTextField = .document.all.Item("txtPart")
         myTextField.Value = "1229G1619"
         ie.document.forms(0).submit
         Do Until .readyState = 4: DoEvents: Loop
         Do While .busy: DoEvents: Loop
         Set doc = ie.document
          
         For Each I In doc.all
             If I.nodename = "TABLE" Then
                 Set t = I
             End If
         Next I
         Set rng = Range("A1")
         For Each r In t.Rows
    
         For Each c In r.Cells
             rng.Value = c.innerText
             Set rng = rng.Offset(, 1)
             I = I + 1
         Next c
    
         Set rng = rng.Offset(1, -I)
         I = 0
         Next r
            
    End With
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this code, I don't have a userid and password, but I could get it to the failed login part.

Code:
Sub testlogin()
Dim IE As Object
        Set IE = CreateObject("InternetExplorer.Application")
        With IE
            .navigate "http://xpresswayplus.arvinmeritor.com/Login.aspx"
            Do While .busy: DoEvents: Loop
            Do While .ReadyState <> 4: DoEvents: Loop
            .Visible = True
            With .document.forms(frmlogin)
                .txtUserId.Value = "testyuser" 'Change to YOUR Login ID
                .txtPasswd.Value = 1234 'Change to YOUR password
                .btnLogin.Click
            End with
            Do While .busy: DoEvents: Loop
            Do While .ReadyState <> 4: DoEvents: Loop
        .navigate "http://www.xpresswayplus.com/webapp/magec/servlet/Production" 
         Do Until .readyState = 4 
             DoEvents 
         Loop 
         Set myTextField = .document.all.Item("txtPart") 
         myTextField.Value = "1229G1619" 
         ie.document.forms(0).submit 
         Do Until .readyState = 4: DoEvents: Loop 
         Do While .busy: DoEvents: Loop 
         Set doc = ie.document 
          
         For Each I In doc.all 
             If I.nodename = "TABLE" Then 
                 Set t = I 
             End If 
         Next I 
         Set rng = Range("A1") 
         For Each r In t.Rows 
    
         For Each c In r.Cells 
             rng.Value = c.innerText 
             Set rng = rng.Offset(, 1) 
             I = I + 1 
         Next c 
    
         Set rng = rng.Offset(1, -I) 
         I = 0 
         Next r 
            
    End With
set IE = Nothing 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,561
Members
449,038
Latest member
Guest1337

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