sappunni
06-12-2009, 06:35 AM
Hello,
I am trying to read the value of a table data cell from IE thru VBA.
The table data cell does have an ID, here is the sample HTML code
<tr>
<td width="20%" id="member_name_txt" class="tip" nowrap>Member Name</td>
<td width="20%">Jane Doe</td>
<td width="20%" id="member_id_txt" class="tip" nowrap>Member ID</td>
<td width="40%">123456789123</td>
</tr>
<tr>
<td id="address_txt" class="tip" nowrap>Address</td>
<td colspan="3">1234 AnyRoad DR </td>
</tr>
<tr>
<td></td>
<td colspan="3">AnyTown, IN 12345-0000</td>
</tr>
For example, I want to read the words Jane Doe for the TD id member_name_txt.
I tried something like this:
webpage = ie.document.body.innertext
Webpage_Range.Offset(i - 1, j) = webpage
startpos = InStr(endpos, webpage, "member_name_txt") + 25
endpos = InStr(startpos, webpage, vbNewLine)
Length = endpos - startpos
webname = Mid(webpage, startpos, Length)
Is there a better way of accessing the table data cell using the ID ?
Thanks and appreciate any help !!!
I am trying to read the value of a table data cell from IE thru VBA.
The table data cell does have an ID, here is the sample HTML code
<tr>
<td width="20%" id="member_name_txt" class="tip" nowrap>Member Name</td>
<td width="20%">Jane Doe</td>
<td width="20%" id="member_id_txt" class="tip" nowrap>Member ID</td>
<td width="40%">123456789123</td>
</tr>
<tr>
<td id="address_txt" class="tip" nowrap>Address</td>
<td colspan="3">1234 AnyRoad DR </td>
</tr>
<tr>
<td></td>
<td colspan="3">AnyTown, IN 12345-0000</td>
</tr>
For example, I want to read the words Jane Doe for the TD id member_name_txt.
I tried something like this:
webpage = ie.document.body.innertext
Webpage_Range.Offset(i - 1, j) = webpage
startpos = InStr(endpos, webpage, "member_name_txt") + 25
endpos = InStr(startpos, webpage, vbNewLine)
Length = endpos - startpos
webname = Mid(webpage, startpos, Length)
Is there a better way of accessing the table data cell using the ID ?
Thanks and appreciate any help !!!