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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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