Get The Value Inside Nested Tables And Divs Using Vba
I have tried multiple solutions posted around and yet to get the code working. I would like to copy/paste value from a website into an Excel Sheet. Here is some of the HTML: The va
Solution 1:
Try
Dim nodeList AsObject, i AsLongSet nodeList = objIE.document.querySelectorAll("td.a71c .a71")
For i = 0To nodeList.Length -1
Debug.Print nodeList.item(i).innerText
Next
Or
Set nodeList objIE.document.querySelectorAll("#oReportCell .a71")
and then same loop as above.
Is there a parent iframe/frame to be handled would be another thought.
Full code something like:
OptionExplicitPublicSub GrabLastNames()
Dim objIE As InternetExplorer, t AsDate, nodeList AsObject, i AsLongConst MAX_WAIT_SEC AsLong = 5Set objIE = New InternetExplorer
With objIE
.Visible = True
.navigate "https://jetblue.rosterapps.com/GenerateReport.aspx?command=6Rqw0HG%2FJQvTea2EXxyC%2BSDRGUzjdE2GHNUaN5rcKVPdKRpHBhRkfYa3c%2FnPLk58WnTYk6kBq1OZHQYsWqgM8g%3D%3D&action=render"DoWhile .Busy = TrueOr .readyState <> 4: DoEvents: Loop
t = Timer
Do
DoEvents
OnErrorResumeNextSet nodeList = .document.querySelectorAll("#oReportCell .a71")
OnErrorGoTo0If Timer - t > MAX_WAIT_SEC ThenExitDoLoopWhile nodeList IsNothingIfNot nodeList IsNothingThenWith ThisWorkbook.Worksheets("Sheet3")
For i = 0To nodeList.Length - 1
.Cells(1, i + 1) = nodeList.item(i).innerText
NextEndWithEndIf
.Quit
EndWithEndSub
Post a Comment for "Get The Value Inside Nested Tables And Divs Using Vba"