Log in

View Full Version : IE Automation using VBA



csqrd
07-12-2010, 05:10 AM
Hi,

I am kind of new to VBA and automation.

Actually I am trying to automate the below process,

Open a new browser, goto the URL
Supply credentials and login
In the next page click on a explorer icon present in that page

I tried to do some coding and i have been successful only till opening the page and after seems like impossible to me... :banghead:

Below is the code of what i have done so far,



Public Sub ie()
Dim ie As Object
Dim lform As Object

Set ie = CreateObject("internetexplorer.Application")
ie.navigate2 "******"
Do Until ie.readystate = 4
DoEvents
Loop
ie.Visible = True ' optional
Set lform = ie.document.forms(0)
With lform
lform("username").Value = "****"
lform("password").Value = "****"
lform.submit
End With
ie.Quit
Set ie = Nothing
End Sub





Please help me with the remaining, excel vba or vbs anyway is fine with me, since my aim is to automate the process. :mkay
The site that i am trying to code in the url part is,
h ttps://extcitrix.wellpoint.com(pls remove the space between 'h' and 'ttps')

Please reply if you need any more details

Thanks in advance for your help. :thumb

Crocus Crow
07-12-2010, 10:47 AM
View the HTML source to determine the form field names.

Also you probably want to delete the Quit and Nothing lines, otherwise IE will disappear after the login.

csqrd
07-13-2010, 04:09 AM
hi

its a java scripted page thats where am struck am not able to get the user name and password values

Crocus Crow
07-13-2010, 06:05 AM
Both values are viewable if you look for them. The user name input box is in plain HTML in the web page source. The password box is generated by Javascript, but the script just writes HTML to the web page - look at the ns_showpwd() function in https://extcitrix.wellpoint.com/vpn/login.js.

Public Sub IE_Login()
Dim IE As Object
Dim lform As Object

Set IE = CreateObject("InternetExplorer.Application")
With IE
.Navigate2 "https://extcitrix.wellpoint.com"
Do Until .ReadyState = 4
DoEvents
Loop
.Visible = True
Set lform = .Document.forms(0)
With lform
.Item("login").Value = "Your Username"
.Item("passwd").Value = "Your Password"
.submit
End With
Do Until .ReadyState = 4
DoEvents
Loop
End With
End Sub