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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

tightwad

Well-known Member
Joined
Feb 22, 2006
Messages
609
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
 

Watch MrExcel Video

Forum statistics

Threads
1,113,992
Messages
5,545,373
Members
410,679
Latest member
rolandbianco
Top