Reputation:
I have a tr which is a object and has td. I want to get all td in another object variable tblTD. For that i used Set tblTD = tr.getelementsbytagname("td")
. But when i check the lenght of tblTD it shows as 0. Can someone suggest how this can be done. Kindly refer the images attached. Thanks!
Upvotes: 3
Views: 10372
Reputation: 2982
If you've set tr
with the getElementsByTagName
function, then you'll need to iterate through each tr object to get the child td objects (or you can just reference a single one):
Dim td As MSHTML.IHTMLElementCollection
Dim tr As MSHTML.IHTMLElementCollection
Dim trObj as MSHTML.HTMLGenericElement
Dim tdObj as MSHTML.HTMLGenericElement
Set tr = HTMLDoc.getElementsByTagName("tr")
For Each trObj In tr
Set td = trObj.getElementsByTagName("td")
For Each tdObj in td
'do something with each td object'
Next
Next
Upvotes: 4