yvonne_yuan
New Member
- Joined
- Apr 19, 2016
- Messages
- 9
Hi everyone, I'm new beginner for VBA programing and I'm trying to automate Internet Explorer using Excel VBA.
I'm facing a issue on how to insert value within an HTML table, I'm pretty sure I have the correct td since the following always reports the expected data.
but I ran below code the value display in the cell but changed to empty immediately.
and one more thing, if i double click the cell manually, a new input tag will be display under a div tab, but i use ondblclick fireevent, the input tag is not generated, so I'm wandering how does the input tag enable in the html source???
My VBA code:
If Not IE.document.getElementById("PSRTABLE_AFFECTEDITEMS") Is Nothing Then
For Each tr In IE.document.getElementById("PSRTABLE_AFFECTEDITEMS").getElementsByTagName("tr")
If tr.className = "GMDataRow" And tr.getElementsByTagName("td").Length > 2 Then
tr.getElementsByTagName("td")(1).Focus
tr.getElementsByTagName("td")(1).FireEvent "ondblclick"
part of HTML table source code: please see attachment
<tbody>
<tr>
<th style="height:0px;width:194px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:23px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:73px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:95px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:181px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:86px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:79px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:5px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:1px;"></th>
<th style="height:0px;width:14px;"></th>
<th style="height:0px;width:1px;"></th>
<th style="height:0px;width:14px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height: 0px; width: 1px;"></th>
<th style="height: 0px; width: 0px;"></th>
</tr>
<tr class="GMDataRow" style="height: 21px;">
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Cisco Unified SIP Phone 3905, Charcoal, Standard Handset </td>
<td style="background-color: rgb(201, 221, 255);" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">900046014-2 </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">DOA- DEAD ON ARRIVAL </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Y</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Y</td>
Any help would be appreciated.
I'm runningIE11 & Excel 2013
I'm facing a issue on how to insert value within an HTML table, I'm pretty sure I have the correct td since the following always reports the expected data.
but I ran below code the value display in the cell but changed to empty immediately.
and one more thing, if i double click the cell manually, a new input tag will be display under a div tab, but i use ondblclick fireevent, the input tag is not generated, so I'm wandering how does the input tag enable in the html source???
My VBA code:
If Not IE.document.getElementById("PSRTABLE_AFFECTEDITEMS") Is Nothing Then
For Each tr In IE.document.getElementById("PSRTABLE_AFFECTEDITEMS").getElementsByTagName("tr")
If tr.className = "GMDataRow" And tr.getElementsByTagName("td").Length > 2 Then
tr.getElementsByTagName("td")(1).Focus
tr.getElementsByTagName("td")(1).FireEvent "ondblclick"
part of HTML table source code: please see attachment
<tbody>
<tr>
<th style="height:0px;width:194px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:23px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:73px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:95px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:181px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:86px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:79px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:5px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:30px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:280px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:1px;"></th>
<th style="height:0px;width:14px;"></th>
<th style="height:0px;width:1px;"></th>
<th style="height:0px;width:14px;"></th>
<th style="height:0px;width:55px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height:0px;width:80px;"></th>
<th style="height:0px;width:20px;"></th>
<th style="height: 0px; width: 1px;"></th>
<th style="height: 0px; width: 0px;"></th>
</tr>
<tr class="GMDataRow" style="height: 21px;">
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Cisco Unified SIP Phone 3905, Charcoal, Standard Handset </td>
<td style="background-color: rgb(201, 221, 255);" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">900046014-2 </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">DOA- DEAD ON ARRIVAL </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Y</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Y</td>
Any help would be appreciated.
I'm runningIE11 & Excel 2013