Looping through HTML Elements

Peter h

Active Member
Joined
Dec 8, 2015
Messages
417
Hey guys. I've been all over google, and can't seem to find what I'm looking for. I'm trying to loop through all the elements of a website, and record the element's ID. I'm not sure how to store the object's id. Here's what I got so far:

Code:
Dim o As Object
For Each o In IE.Document.All
            mapWS.Cells(lRow, i * 3) = IE.Document.getElementByID(o).innertext
            mapWS.Cells(lRow, (i * 3) + 1) = o.innertext
            lRow = lRow + 1
        Next o
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Doesn't the loop variable o represent each element in the document as you are looping?

If so to get it's ID, if it has one, you would use o.id.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top