Bump. Please Help.
Bump. Please Help.
Last edited by Beast_OnThe_Keys; 09-18-2019 at 09:28 AM.
Good Afternoon Folks!
Here again with a problem that has been frustrating me for the last 12 hours.
I am writing some VBA that allows me to automatically log in to a password protected site, navigate me to a table, pop into a data toggle tab, select multiple check boxes, searches results, copy and pastes them from HTMi table to worksheet.
Currently my code successfully;
1. Logs me in
2. Navigates me to table
3. Pops into data toggle tab (where multiple check boxes are for additional criteria you would like to add)
4. Checks one box (the first element i reference)
Then i get a runtime error saying Object required.
I guess my question for now is how do I reference another element check box to be ".Clicked"?
Code Below
Sub ImportData()
Dim ie As Object
Dim objCollection As Object
Set ie = CreateObject("internetexplorer.application")
With ie
ie.Visible = True
ie.Navigate "WEBPAGE"
Do While .Busy
DoEvents
Loop
Do While .ReadyState <> 4
DoEvents
Loop
End With
Set Email = ie.Document.getElementById("ELEMENT ID")
Email.Value = "john@examplecom"
Set Password = ie.Document.getElementById("ELEMENT ID")
Password.Value = "PASSWORD"
Set submit = ie.Document.getElementById("ELEMENT ID")
submit.Click
With ie
.Navigate "WEBPAGE"
Do While .Busy
DoEvents
Loop
Do While .ReadyState <> 4
DoEvents
Loop
End With
ie.Visible = True
Set Doc = ie.Document
Dim links, link
Dim j As Integer
j = 0
Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getElementsByTagName("a")
n = links.Length
While j <= n
links(j).Click
While ie.Busy
DoEvents
Wend
ie.Document.getElementById("ELEMENT ID CHECKBOX 1").Click
Do While ie.Busy
DoEvents
Loop
Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getelementsbytagname("a")
j = j + 2
My code works up until here. The second element checkbox I need to have clicked is below but again getting Object Required run time error
Wend
ie.Document.getElementById("ELEMENT ID CHECKBOX 2").Click
Do While ie.Busy
DoEvents
Loop
Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getelementsbytagname("a")
j = j + 2
End Sub
I have about 7-8 uniquely named elements, or check boxes, or both (or whatever they are defined as, I am new to VBA) that I need to have selected before I hit the submit button and update the table. Thought I could nest them kinda like an IF statement but guess not. I haven't even started looking at the copy and paste to workbook/sheet function so any pointers going into that would be greatly appreciated if this is an easy fix.
I greatly appreciate your time,
Cheers!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks