gemsera
07-30-2008, 03:52 AM
Hi All,
Sorry to have to ask but after trawling the web for two days and mucking around with sendkeys, its still not doing what I want. My code is here: (bear in mind its ugly, but it works)
Sub SPIRtest()
redo:
MyLogin = "603889262"
MyToken = Application.InputBox("Please enter your ActivID Token Number", "Token", Default:="", Type:=1)
MyPass = "mypasshere"
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
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(2).Value = MyToken
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(3).Value = ""
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(4).Value = MyPass
Application.Wait (Now + TimeValue("00:00:02"))
DoEvents
Call SendKeys("{enter}") 'Hit enter on the "login" button
End If
Application.Wait (Now + TimeValue("00:00:05"))
ie.Navigate "next page-secondary login"
Application.Wait (Now + TimeValue("00:00:05"))
DoEvents
Call SendKeys(MyLogin) 'This is the login name box
DoEvents
Call SendKeys("{tab}") 'tab to password box
DoEvents
Call SendKeys(MyPass) 'Password box
DoEvents
Call SendKeys("{enter}") 'Hit enter on the "login" button
' goto Search Query
Application.Wait (Now + TimeValue("00:00:10"))
ie.Navigate "SEARCHQUERY HTML HERE"
Application.Wait (Now + TimeValue("00:00:05"))
' Goto Search Fields Page
Dim objIE As SHDocVw.InternetExplorer
Dim ieDoc As MSHTML.HTMLDocument
Dim btnSubmit As MSHTML.HTMLInputElement
Set ieDoc = ie.Document
Set btnExport = ieDoc.all.Item("export")
btnExport.Click
Application.Wait (Now + TimeValue("00:00:10"))
ie.Visible = True
Dim Doc As HTMLDocument
Set Doc = ie.Document
With Doc.getElementsByName("checkBoxList(Search)")
ieDoc.Item(0).Checked = True 'Entered
End With
Call SendKeys("{TAB 27}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 4}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 3}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 4}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
Set ieDoc = ie.Document
Set btnExport = ieDoc.all.Item("Export")
btnExport.Click
Next
End
End Sub
I have to login to one page (with a random changing number), navigate to the next, login there, navigate to the search, hit export, select some checkboxes and then hit export again. I can get to the page where the checkboxes are, but cannot for the life of me select the right checkboxes to proceed any further.
Unfortunately I dont know the names of the checkboxes, as the page is encrypted and beyond my league in programming. any suggestions? :dunno
Thanking all in advance.
Sorry to have to ask but after trawling the web for two days and mucking around with sendkeys, its still not doing what I want. My code is here: (bear in mind its ugly, but it works)
Sub SPIRtest()
redo:
MyLogin = "603889262"
MyToken = Application.InputBox("Please enter your ActivID Token Number", "Token", Default:="", Type:=1)
MyPass = "mypasshere"
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
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(2).Value = MyToken
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(3).Value = ""
Application.Wait (Now + TimeValue("00:00:02"))
ieForm(4).Value = MyPass
Application.Wait (Now + TimeValue("00:00:02"))
DoEvents
Call SendKeys("{enter}") 'Hit enter on the "login" button
End If
Application.Wait (Now + TimeValue("00:00:05"))
ie.Navigate "next page-secondary login"
Application.Wait (Now + TimeValue("00:00:05"))
DoEvents
Call SendKeys(MyLogin) 'This is the login name box
DoEvents
Call SendKeys("{tab}") 'tab to password box
DoEvents
Call SendKeys(MyPass) 'Password box
DoEvents
Call SendKeys("{enter}") 'Hit enter on the "login" button
' goto Search Query
Application.Wait (Now + TimeValue("00:00:10"))
ie.Navigate "SEARCHQUERY HTML HERE"
Application.Wait (Now + TimeValue("00:00:05"))
' Goto Search Fields Page
Dim objIE As SHDocVw.InternetExplorer
Dim ieDoc As MSHTML.HTMLDocument
Dim btnSubmit As MSHTML.HTMLInputElement
Set ieDoc = ie.Document
Set btnExport = ieDoc.all.Item("export")
btnExport.Click
Application.Wait (Now + TimeValue("00:00:10"))
ie.Visible = True
Dim Doc As HTMLDocument
Set Doc = ie.Document
With Doc.getElementsByName("checkBoxList(Search)")
ieDoc.Item(0).Checked = True 'Entered
End With
Call SendKeys("{TAB 27}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 4}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 3}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Call SendKeys("{TAB 4}")
DoEvents
Call SendKeys("{ }")
Application.Wait (Now + TimeValue("00:00:01"))
Set ieDoc = ie.Document
Set btnExport = ieDoc.all.Item("Export")
btnExport.Click
Next
End
End Sub
I have to login to one page (with a random changing number), navigate to the next, login there, navigate to the search, hit export, select some checkboxes and then hit export again. I can get to the page where the checkboxes are, but cannot for the life of me select the right checkboxes to proceed any further.
Unfortunately I dont know the names of the checkboxes, as the page is encrypted and beyond my league in programming. any suggestions? :dunno
Thanking all in advance.