Can someone tell me how to double click HTML table cell to input value to td

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
<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>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">
<img class="gridIconSize" src="/Agile/static/7edfadf3763ac1170dfb6eb026ed98d0/images/ico_status_no_read_priv.png" title="No Privilege"> 
</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">No</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus 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">-E0  </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">JPN  </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">PID</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">1</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">0</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">0</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">Introductory</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">
<a tabindex="-1" href="javascript:noaction();" ***********="showQuickViewLink(event, this)" **********="cancelQuickViewTimer(this);" *******="javascript:displayObject('PartFamilyHandler', '2000004409', '6023882', '0');" class="image_link" infourl="showObjectInfo('2000004409', '6023882', '0' , '6671', 'R0', 'false', 'PSRTABLE_AFFECTEDITEMS');">PHONE</a> 
</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">
<img class="gridIconSize" src="/Agile/static/7edfadf3763ac1170dfb6eb026ed98d0/images/ico_status_no_read_priv.png" title="No Privilege"> 
</td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">
<img class="gridIconSize" src="/Agile/static/7edfadf3763ac1170dfb6eb026ed98d0/images/ico_status_no_read_priv.png" title="No Privilege"> 
</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=" 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=" GMColorReadOnly GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell GMEmpty" colspan="2"> </td>
<td style="background-color:rgb(255,255,255)" class=" GMColorNoFocus GMRow GMText GMCell" colspan="2">
<img class="gridIconSize" src="/Agile/static/7edfadf3763ac1170dfb6eb026ed98d0/images/ico_status_no_read_priv.png" title="No Privilege"> 
</td>
<td class=" GMRow GMHtml GMCellEmpty GMEmpty" colspan="2"> </td>
</tr>
</tbody>
 
Upvote 0
Hi John,
my url could not be opened in extranet, and I can't upload the image from my PC, I can see that see the difference of source before double click and after double click manully, you can see below.

I tried to use .fireevent ondblclick and .fireevent onmousedown, but it does not work, can you tell me how to fix this issue? I just want to insert value to html table cells, and the cells input will be displayed only after user double click the cell.


Before double click html code:
< div class="grid_read_div" style="left: 0px; top: 0px; display: none;" id="gridTablePanel">< /div>

After double click the html code:

< select id="C2" class="htmlElm" style="width: 53px;" onkeydown="AGILE.grid.HTMLElementMgr.validateEvent(event)"><option value="-1" selected=""></option><option value="2658527">Cancel</option><option value="2658526">No</option><option value="2658525">Yes</option>< /select>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top