So i got everything working to go to the website, enter in the username and password but i don't know how to change this so that it clicks the "sign in" button.
Of course this is not working since the code for the button is as follows:
So how i would i write the above so that it clicks the button by Class?
Code:
Private Sub Open_multiple_sub_pages_from_main_page()
Dim i As Long
Dim IE As Object
Dim Doc As Object
Dim objElement As Object
Dim objCollection As Object
Dim buttonCollection As Object
Dim valeur_heure As Object
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
' You can uncoment Next line To see form results
IE.Visible = True
' Send the form data To URL As POST binary request
IE.navigate "https://illinois.tylerhost.net/OfsWeb/FileAndServeModule"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend
Set objCollection = IE.document.getElementsByTagName("input")
'Set objCollection = IE.document.getElementsByClassName("btn btn-primary")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "UserName" Then
' Set text for search
objCollection(i).Value = "me@somewhere.com"
End If
If objCollection(i).Name = "Password" Then
' Set text for search
objCollection(i).Value = "mypassword"
End If
If objCollection(i).Class = "btn btn-primary" Then ' submit button if found and set
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click ' click button to load page
While IE.Busy
DoEvents
Wend
' Show IE
IE.Visible = True
Set Doc = IE.document
Dim links, link
Dim j As Integer 'variable to count items
j = 0
Set links = IE.document.getElementById("dgTime").getElementsByTagName("a")
n = links.Length
While j <= n 'loop to go thru all "a" item so it loads next page
links(j).Click
While IE.Busy
DoEvents
Wend
'-------------Do stuff here: copy field value and paste in excel sheet. Will post another question for this------------------------
IE.document.getElementById("DetailToolbar1_lnkBtnSave").Click 'save
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now) 'wait
Loop
IE.document.getElementById("DetailToolbar1_lnkBtnCancel").Click 'close
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now) 'wait
Loop
Set links = IE.document.getElementById("dgTime").getElementsByTagName("a")
j = j + 2
Wend
End Sub
Of course this is not working since the code for the button is as follows:
HTML:
Sign In
So how i would i write the above so that it clicks the button by Class?
Last edited by a moderator: