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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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,215,200
Messages
6,123,612
Members
449,109
Latest member
Sebas8956

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