Reputation: 2801
I have managed to take a table and break it down into an MSHTML.IHTMLElementCollection
Here is an example of the tableCells.Item(1).innerHTML
which each item looks the same. I'm now looking to extract the values of p_samptype
which would be MyType
and also 3.8300
.
<TD>ABC123</TD>
<TD align=center><INPUT type=hidden value=001 name=p_ordno><B>001</B></TD>
<TD align=center><INPUT style="WIDTH: 165px" maxLength=40 value=123 name=p_sampdesc><INPUT type=hidden value=123 name=p_orig_sampdesc></TD>
<TD align=center><INPUT disabled id=p_samptype style="WIDTH: 115px" maxLength=15 value="MyType" name=p_samptype><SPAN style="WIDTH: 5px"></SPAN><INPUT type=hidden value="MyType" name=p_orig_samtype></INPUT><INPUT type=hidden value=1 name=p_tier></TD>
<TD align=right>3.8300</TD>
<TD align=center>2021/07/06</TD>
Here is how I get tableCells
Dim doc As MSHTML.HTMLDocument
Set doc = New MSHTML.HTMLDocument
Dim tableCells As MSHTML.IHTMLElementCollection
Set tableCells = GetHTMLTable(URLStr, TableStr, doc)
Debug.Print tableCells.Item(1).innerHTML
Upvotes: 0
Views: 274
Reputation: 84465
I think you should be declaring as MSHTML.HTMLTable then you can access with .rows() and .children()
e.g.
Dim table As MSHTML.HTMLTable: Set table = GetHTMLTable(URLStr, TableStr, doc)
Debug.Print table.rows(0).children(3).children(0).value
Debug.Print table.rows(0).children(4).innertext
Upvotes: 1
Reputation: 2801
I was able to use a mixture of
tableCells.Item(i).getElementsByTagName("td")(1).innerText
and
tableCells.Item(i).getElementsByTagName("td")(2).innerHTML
The innerHTML
will require further string manipulation though, but I'm unsure of a better way atm.
Upvotes: 0