title: Clicking Table Row in HTML Table using VBA
body: <p>I am attempting to create an automation tool in Excel using VBA which runs and downloads a database query from a website portal. The tool is almost completely functional, but the one step I just cannot figure out is the query selection. </p>
  
  <p>Once the user has searched for the query in the portal, applicable queries are put into rows within a HTML table. There are two ways a user can run a query: double-click a row OR click a row and then click another button in the portal. My difficulty is that I am unable to preform either of these tactics even after hours of research. </p>
  
  <p>The HTML code for the first row of the table (which is the desired query) is seen below. I included the td tags so you could also see the cells within the row.</p>
  
  <pre><code>&lt;TABLE class="x-grid-table x-grid-table-resizer" style="WIDTH: 1867px" cellSpacing=0 cellPadding=0 border=0&gt;
      &lt;TBODY&gt;
          &lt;TR class="x-grid-row " _nodup="30806" viewIndex="0" viewRecordId="ext-record-17" boundView="objectgridview"&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-gridcolumn-1085   x-grid-cell-first" rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;
                      &lt;SPAN class="grid-icon view-16"&gt;&lt;/SPAN&gt;
                      &lt;SPAN&gt;QUERYNAME&lt;/SPAN&gt; 
                  &lt;/DIV&gt;
              &lt;/TD&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-gridcolumn-1086   " rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;QUERYTYPE&lt;/DIV&gt;&lt;/TD&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-gridcolumn-1087   " rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;QUERYDESCRIPTION&lt;/DIV&gt;
              &lt;/TD&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-gridcolumn-1088   " rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;QUERYLIBRARY&lt;/DIV&gt;
              &lt;/TD&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-gridcolumn-1089   " rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;QUERYOWNER&lt;/DIV&gt;
              &lt;/TD&gt;
              &lt;TD class=" x-grid-cell x-grid-cell-datecolumn-1090    x-grid-cell-last" rowSpan="1" colSpan="1"&gt;
                  &lt;DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left"&gt;QUERYDATE&lt;/DIV&gt;
              &lt;/TD&gt;     
          &lt;/TR&gt;
      &lt;/TBODY&gt;
  &lt;/TABLE&gt;
  </code></pre>
  
  <p>I also looked at the HTML in Chrome, with the only other difference being that the tr classname switches to "x-grid-row x-grid-row-over" when the mouse cursor is over that row and "x-grid-row x-grid-row-selected x-grid-row-over-focused" when the row is clicked.</p>
  
  <p>As mentioned I have tried a number of methods to click on this row. I was able to use getElementsByTagName is identify the row/table/others element, but even after finding this I still couldn't find success.</p>
  
  <p>Some of the code lines that I have used are below.</p>
  
  <pre><code>IE.document.getElementsByTagName("tr")(42).Classname = "x-grid-row x-grid-row-selected x-grid-row-focused"
  IE.document.getElementsByTagName("table")(20).Rows(0).Click
  IE.document.getElementsByTagName("tr")(42).getElementsByTagName("td")(3).getElementsByTagName("div")(0).Click
  IE.document.getElementsByTagName("tr")(42).getElementsByTagName("td")(3).Selected = True
  Call IE.document.getElementsByTagName("tr")(42).execScript("mouseup()", "Javascript")
  
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.SendKeys ("-{F10}")
  WshShell.SendKeys "{DOWN}"
  WshShell.SendKeys "{ENTER}"
  </code></pre>
  
  <p>I am hoping someone might be able to provide some knowledge that I am missing. Thanks!</p>