# Login to webpage



## chvinodhk (Jul 17, 2012)

Hi,

Iam using the below code to login to a webpage, but getting error:91 at UserIDInputBox.Value = cUserID. Request to solve the problem

Sub Test()
Const cURL = "https://caps.icicibank.com/finnsso/gateway/SSOGateway?requestID=7000003"
Const cUserID = "ID"
Const cPassword = "Pswrd"

Dim ie As InternetExplorer
Dim doc As HTMLDocument
Dim ieTable As Object
Dim clip As DataObject
Dim LoginForm As HTMLFormElement
Dim UserIDInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim LogInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Dim qt As QueryTable

Set ie = New InternetExplorer

ie.Visible = True
ie.navigate cURL

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy: DoEvents: Loop

Set doc = ie.document

Set LoginForm = doc.forms(0)

Set UserIDInputBox = LoginForm.elements("User ID")
UserIDInputBox.Value = cUserID

Set PasswordInputBox = LoginForm.elements("Password")
PasswordInputBox.Value = cPassword

Set LogInButton = LoginForm.elements("submit")
LogInButton.Click

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy: DoEvents: Loop

ie.navigate "http://gencollectpro.intranet.genpact.com/GenCollect/Download_PickupList.aspx"
Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop
Set doc = ie.document
Set ieTable = doc.all.Item("Pickup List")

If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "" & ieTable.outerHTML & ""
clip.PutInClipboard
Sheet1.Select
Sheet1.Range("A1").Select
Sheet1.PasteSpecial "Unicode Text"
End If

End Sub

Regards
Vinodh


----------

