PDA

View Full Version : Internet Explorer controls error



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

gemsera
07-25-2008, 05:27 AM
p.s Yes I have googled, and that is how I got the majority of my knowledge/code up til this point. I am a complete noob at all this however it will save me having to do a very expensive course for the purpose of one file... Any links to any other knowledge bases would be great as I'm more than willing to learn! :)

gemsera
07-25-2008, 05:31 AM
I have now found out that the site requires you to type the entry in manually, it must do a check on each digit as it is entered or something fancy. If anyone has any brainwaves on that length then please let me know, otherwise not to matter and thanks for reading :)

Aussiebear
07-25-2008, 05:59 AM
G'day gemsera,

Welcome to the forum. Someone may well have an answer for you in the near while. Please be patient.

gemsera
07-25-2008, 06:26 AM
G'day gemsera,

Welcome to the forum. Someone may well have an answer for you in the near while. Please be patient.
Thanks Aussiebear, you come from my homestate yay! :) Oh i'm patient I've just got lots of techheads around but they are only helpful when they want to be :)

Hoping to learn alot here :)