gemsera
07-25-2008, 05:26 AM
Hi All,
A family member suggested I post a question here as you guys are the best - and even he is stumped with this one!
I run a daily report for work, which involves logging into a page, navigating to another and logging in there, running a search and using the export to excel function. I'm not looking for anyone to write this for me, just a little assistance with an error.
Ideally I would like to be able to drag the table down and import into excel, with the login and navigation in IE automated. I am currently able to prompt for the username, password and token id (randomly generated RFID token), open IE and insert these details, but the page returns a invalid username/pass message. When I insert the values manually, it works fine.
As it is quite secure I will post examples where I can, and here is my code:
Sub SPIRtest()
redo:
MyLogin = Application.InputBox("Please enter EIN", "EIN", Default:="XXXXXX", Type:=1)
MyToken = Application.InputBox("Please enter your ActivID Token Number", "Token", Default:="", Type:=1)
MyPass = Application.InputBox("Please enter your Password", "Password", Default:="SXXXX", Type:=2)
If MyLogin = "" Or MyPass = "" Or MyToken = "" Then GoTo redo
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "linkgoeshere"
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
'Look for password Form by finding test "Password"
For Each ieForm In ie.Document.forms
If InStr(ieForm.innertext, "password") <> 0 Then
ULogin = True
'enter details
ieForm(1).Value = MyLogin
ieForm(2).Value = MyToken
ieForm(3).Value = ""
ieForm(4).Value = MyPass
'wait 5 seconds
Application.Wait (Now + TimeValue("00:00:05"))
'login
ieForm.submit
Exit For
Else
End If
Next
If ULogin = False Then MsgBox "User is aleady logged in"
Set ie = Nothing
End Sub
Please note in the HTML for the login page, there is alot of javascript, including for the form. There is a blank "hidden" input tag before the password one, hence the "" line.
Does anyone know any reason why this may not work? If need be I can scrub the html and post that as well. Thanking everyone in advance! :thumb
A family member suggested I post a question here as you guys are the best - and even he is stumped with this one!
I run a daily report for work, which involves logging into a page, navigating to another and logging in there, running a search and using the export to excel function. I'm not looking for anyone to write this for me, just a little assistance with an error.
Ideally I would like to be able to drag the table down and import into excel, with the login and navigation in IE automated. I am currently able to prompt for the username, password and token id (randomly generated RFID token), open IE and insert these details, but the page returns a invalid username/pass message. When I insert the values manually, it works fine.
As it is quite secure I will post examples where I can, and here is my code:
Sub SPIRtest()
redo:
MyLogin = Application.InputBox("Please enter EIN", "EIN", Default:="XXXXXX", Type:=1)
MyToken = Application.InputBox("Please enter your ActivID Token Number", "Token", Default:="", Type:=1)
MyPass = Application.InputBox("Please enter your Password", "Password", Default:="SXXXX", Type:=2)
If MyLogin = "" Or MyPass = "" Or MyToken = "" Then GoTo redo
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "linkgoeshere"
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
'Look for password Form by finding test "Password"
For Each ieForm In ie.Document.forms
If InStr(ieForm.innertext, "password") <> 0 Then
ULogin = True
'enter details
ieForm(1).Value = MyLogin
ieForm(2).Value = MyToken
ieForm(3).Value = ""
ieForm(4).Value = MyPass
'wait 5 seconds
Application.Wait (Now + TimeValue("00:00:05"))
'login
ieForm.submit
Exit For
Else
End If
Next
If ULogin = False Then MsgBox "User is aleady logged in"
Set ie = Nothing
End Sub
Please note in the HTML for the login page, there is alot of javascript, including for the form. There is a blank "hidden" input tag before the password one, hence the "" line.
Does anyone know any reason why this may not work? If need be I can scrub the html and post that as well. Thanking everyone in advance! :thumb