ProtoVB ProtoVB - 2 months ago 5x
HTML Question

Vba create collection with HTML elements

I am trying to catch web data using VBA.

I have such HTML lines:

<div class="table-wrapper">
<table class="mega-table">

How can I create a collection for "tbody"? (Later I want to loop through all the elements it contains (all the "tr")).


This should work for what you are after. Basically you want to select the element that contains the table, then select all the TRs of that table.

Updated to include selecting the table body as well.

 dim Elements as Object

 Set Elements = Browser.Document.getElementsByClassName("mega-table")(0).getElementsByTag‌​Name("tbody")‌(0).getElementsByTag‌​Name("tr")‌