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.
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.
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.
<TABLE class="x-grid-table x-grid-table-resizer" style="WIDTH: 1867px" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR class="x-grid-row " _nodup="30806" viewIndex="0" viewRecordId="ext-record-17" boundView="objectgridview">
<TD class=" x-grid-cell x-grid-cell-gridcolumn-1085 x-grid-cell-first" rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">
<SPAN class="grid-icon view-16"></SPAN>
<SPAN>QUERYNAME</SPAN>
</DIV>
</TD>
<TD class=" x-grid-cell x-grid-cell-gridcolumn-1086 " rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">QUERYTYPE</DIV></TD>
<TD class=" x-grid-cell x-grid-cell-gridcolumn-1087 " rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">QUERYDESCRIPTION</DIV>
</TD>
<TD class=" x-grid-cell x-grid-cell-gridcolumn-1088 " rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">QUERYLIBRARY</DIV>
</TD>
<TD class=" x-grid-cell x-grid-cell-gridcolumn-1089 " rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">QUERYOWNER</DIV>
</TD>
<TD class=" x-grid-cell x-grid-cell-datecolumn-1090 x-grid-cell-last" rowSpan="1" colSpan="1">
<DIV class="x-grid-cell-inner " style="TEXT-ALIGN: left">QUERYDATE</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
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.
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.
Some of the code lines that I have used are below.
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}"
I am hoping someone might be able to provide some knowledge that I am missing. Thanks!