Anyone help me here by saying that how to read the nested html table values from a third party application using Excel VBA? as an example below i pasted a part of the HTML source where i want to read the all the value and want to store it into the excel.But in here all are nested tables they used,and the tables don't have any name also in the html source i have seen.
<td>
<table cellspacing="1" cellpadding="0" class="data">
<tr class="colhead">
<th colspan="3">Expression</th>
</tr>
<tr class="colhead">
<th>Field</th>
<th>Operator</th>
<th>Answer</th>
</tr>
<tr class="rowLight">
<td width="40%">
Location Attributes: LOC - Sub Commodity
</td>
<td width="20%">
=
</td>
<td width="40%">
Abrasives
</td>
</tr>
<tr class="rowDark">
<td width="40%">
Location Attributes: LOC - Commodity Tier1
</td>
<td width="20%">
=
</td>
<td width="40%">
Advertising, Sales & Promotion
</td>
</tr>
Thanks, Arup
This is how I read an HTML table:
this uses ADO, but it should be the same for DAO
I looked all over for the answer to this question. I finally found the solution which was actually throuhg recording a macro. I know, you all think you are above this, but it is actually the best way. See the full post here: http://automatic-office.com/?p=344 In short, you want to record the macro and go to data --> from web and navigate to your website and select the table you want.
I have used the above solutions "get element by id" type stuff in the past, and it is great for a few elements, but if you want a whole table, and you aren't super experienced, just record a macro. don't tell your friends and then reformat it to look like your own work so no one knows you used the macro tool ;)
The code looks like this (including all the superfluous setting of default properties to their default values that recording a macro does for you... figure out which are extra and delete them
Enjoy
please find the code below :
This requires references to be set to
Microsoft HTML Object Library
andMicrosoft Internet Controls
I based this off of this page
This is yet another way. The tricky thing is if you have a nested table you must get parent container whether a div, table. Use F12 developer tools in IE or in Chrome and work your way down. In the example below there is a div which contains a table. In the example given in the question there is a table containing a table so you would have to find that parent table and use code similar to this to get the child table. Hope that helps.