Login to a web page & automatically fill in pasword

D

Dave F.

Hi
IE v6.0

This is my 1st attempt at this , so please bear with me.

I want to logon to my banks site & get my stock/shares values to add to a
worksheet.
I need vba to fill in the logon password/ID boxes on the login page for me.

I got to get past the first page that requires the passwords etc, but
there's a second page with a continue button that's stumped me.
It won't accept .click or .submit:

This is as far as I've got:
the ** line is the problem

Have I got the right page/form?

Sub LoginSite()
Dim oIE As New SHDocVw.InternetExplorer
Dim sSearchTerm As String
Dim sURL As String

sSearchTerm = "programically fill out web form"

sURL = '"https://www.mybank.co.uk/frames/login_body.asp"

'open a new, visible IE window
Set oIE = New SHDocVw.InternetExplorer
oIE.Visible = True

'go to desired page
oIE.Navigate sURL

'wait for page to finish loading
Do Until oIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

oIE.Document.all("txtCustomerID").Value = "MyID"
oIE.Document.all("txtPassnumber").Value = "MyPass"
oIE.Document.forms(0).submit
Do Until oIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
' **oIE.Document.forms(0).submit
' This doesn't work either:
' oIE.Document.all("Continue").click
End Sub

This is the source code (& a bit more I think):

<td align="center" valign="bottom">
<table width="50%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="table-light" align="left" valign="bottom"><a
href="/frames/history_reset_redirect.asp?FramesPage=/frames/logoff_body_2.as
p" target="_top""><img border="0" src="../pixels/button_logout.gif"
alt="Log Out" TITLE="Log Out" NAME="Log Out"></a></td>
<td class="table-light" align="right" valign="bottom"><a href="
" target="_self"><img src="../pixels/button_continue.gif" border="0"
alt="continue" TITLE="Continue" NAME="Continue"></a></td>
</tr>
</table>
</td>

There doesn't seem to be a help for the IE object model.. is this correct &
Is there a way to get Intelisnese to work within the the IDE for this?

If there's any other improvements I can make, please feel free to tell me.
Hope you can help.
Dave F.
 
L

losbash

Hi Dave,

I am trying to do something similar and was on the board looking for
solutions...

I started with something like this ....
it filled in the Username and Password ... my problem is that on the
site I am hitting another window opens up which I am trying to figure
out how to close so that the focus is returned to the login window.

_______________________________________________________________________________
Public Sub FillInUserName()
Dim brokerAcct As InternetExplorer
Dim OBJ As Object

Set brokerAcct = New InternetExplorer
brokerAcct.Visible = True
brokerAcct.Navigate "<<login URL>>"
Do Until brokerAcct.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop


'Log on
Set OBJ = brokerAcct.Document.all.Item("userName")
OBJ.Value = "<<USERNAME>>"
Set OBJ = brokerAcct.Document.all.Item("Password")
OBJ.Value = "<<PASSWORD>>"
Set OBJ = brokerAcct.Document.all.Item("<<loginform>>")
ifp.Submit

brokerAcct.Quit
Set brokerAcct = Nothing


End Sub
____________________________________________________________________________
 
S

sal21

Hi Dave,

I am trying to do something similar and was on the board looking for
solutions...

I started with something like this ....
it filled in the Username and Password ... my problem is that on the
site I am hitting another window opens up which I am trying to figure
out how to close so that the focus is returned to the login window.

_______________________________________________________________________________
Public Sub FillInUserName()
Dim brokerAcct As InternetExplorer
Dim OBJ As Object

Set brokerAcct = New InternetExplorer
brokerAcct.Visible = True
brokerAcct.Navigate "<<login URL>>"
Do Until brokerAcct.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop


'Log on
Set OBJ = brokerAcct.Document.all.Item("userName")
OBJ.Value = "<<USERNAME>>"
Set OBJ = brokerAcct.Document.all.Item("Password")
OBJ.Value = "<<PASSWORD>>"
Set OBJ = brokerAcct.Document.all.Item("<<loginform>>")
ifp.Submit

brokerAcct.Quit
Set brokerAcct = Nothing


End Sub
____________________________________________________________________________

I have arranged your code but vba return error (block variable not
dedfined-run time 91) why?


Sub LoginSite()
Dim oIE As New SHDocVw.InternetExplorer
Dim sSearchTerm As String
Dim sURL As String

sSearchTerm = "programically fill out web form"

sURL = "http://liberomail.libero.it/"

'open a new, visible IE window
Set oIE = New SHDocVw.InternetExplorer
oIE.Visible = True

'go to desired page
oIE.Navigate sURL

'wait for page to finish loading
Do Until oIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

oIE.Document.all("Username:").Value = Range("a1")
oIE.Document.all("Password:").Value = Range("b1")
oIE.Document.all("Dominio:").Value = Range("c1")

oIE.Document.forms(0).submit
Do Until oIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
' **oIE.Document.forms(0).submit
' This doesn't work either:
' oIE.Document.all("entra").click
End Sub

TIA, Sal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top