title: VBA: Scraping information from HTML Table
body: <p>I'm trying to pull information from an html table. I want to add each element with in the table to a collection. This is what I have so far.</p>
  
  <pre><code>Dim htmlTable As Object
  Dim coll2 As Collection
  Set coll2 = New Collection
  Set IE = New InternetExplorerMedium
  
  With IE
  '.AddressBar = False
  '.MenuBar = False
  .Navigate ("PASSWORDED SITE")
  .Visible = True
  End With
  
  Set htmlTable = IE.Document.getElementById("ctl00_ContentPlaceHolder1_gvExtract")
  Set tableItem = IE.Document.getElementsByTagName("td")
  With coll2
  For Each tableItem In htmlTable.innerHTML
     .Add tableItem
  Next
  End With
  </code></pre>
  
  <p>I have a problem with this line <code>For Each tableItem In htmlTable.innerText</code> I tried diffent variations of <code>htmlTable.innerText</code> each throwing differant errors.</p>
  
  <p>This is the HTML Extract for the table. </p>
  
  <pre><code>&lt;table class="Grid" id="ctl00_ContentPlaceHolder1_gvExtract" style="border-collapse: collapse;" border="1" rules="all" cellspacing="0"&gt;
          &lt;tbody&gt;&lt;tr class="GridHeader" style="font-weight: bold;"&gt;
              &lt;th scope="col"&gt;Delete&lt;/th&gt;&lt;th scope="col"&gt;Download&lt;/th&gt;&lt;th scope="col"&gt;Extract Date&lt;/th&gt;&lt;th scope="col"&gt;User Id Owner&lt;/th&gt;
          &lt;/tr&gt;&lt;tr class="GridItemOdd" style="background-color: rgb(255, 255, 255);"&gt;
              &lt;td&gt;&lt;a href='javascript:DoPostBack("DeleteExtract", 2942854)'&gt;Delete&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href='javascript:OpenDownloadWindow("../Common/FileDownloader.aspx?fileKey=2942854")'&gt;Work Order Inquiry - Work Order&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;06/20/2017 07:50:37&lt;/td&gt;
              &lt;td&gt;MBMAYO&lt;/td&gt;
          &lt;/tr&gt;&lt;tr class="GridItemEven" style="background-color: rgb(204, 204, 204);"&gt;
              &lt;td&gt;&lt;a href='javascript:DoPostBack("DeleteExtract", 2942836)'&gt;Delete&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href='javascript:OpenDownloadWindow("../Common/FileDownloader.aspx?fileKey=2942836")'&gt;Work Order Inquiry - Work Order&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;06/20/2017 07:39:29&lt;/td&gt;
              &lt;td&gt;MBMAYO&lt;/td&gt;
          &lt;/tr&gt;&lt;tr class="GridItemOdd" style="background-color: rgb(255, 255, 255);"&gt;
              &lt;td&gt;&lt;a href='javascript:DoPostBack("DeleteExtract", 2941835)'&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href='javascript:OpenDownloadWindow("../Common/FileDownloader.aspx?fileKey=2941835")'&gt;Work Order Inquiry - Work Order&lt;/a&gt;&lt;/td&gt;&lt;td&gt;06/20/2017 07:23:54&lt;/td&gt;&lt;td&gt;MBMAYO&lt;/td&gt;
          &lt;/tr&gt;&lt;tr class="GridItemEven" style="background-color: rgb(204, 204, 204);"&gt;
              &lt;td&gt;&lt;a href='javascript:DoPostBack("DeleteExtract", 2941827)'&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href='javascript:OpenDownloadWindow("../Common/FileDownloader.aspx?fileKey=2941827")'&gt;Work Order Inquiry - Work Order&lt;/a&gt;&lt;/td&gt;&lt;td&gt;06/20/2017 07:16:16&lt;/td&gt;&lt;td&gt;MBMAYO&lt;/td&gt;
          &lt;/tr&gt;&lt;tr class="GridItemOdd" style="background-color: rgb(255, 255, 255);"&gt;
              &lt;td&gt;&lt;a href='javascript:DoPostBack("DeleteExtract", 2941822)'&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href='javascript:OpenDownloadWindow("../Common/FileDownloader.aspx?fileKey=2941822")'&gt;Work Order Inquiry - Work Order&lt;/a&gt;&lt;/td&gt;&lt;td&gt;06/20/2017 07:14:06&lt;/td&gt;&lt;td&gt;MBMAYO&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;&lt;/table&gt;
  </code></pre>
  
  <p>The goal is to store each <code>&lt;td&gt;</code> as an item for a collection and then retrieve the date for example <code>&lt;td&gt;06/20/2017 07:50:37&lt;/td&gt;</code> from it. This table Grows so I think an array is out of the question?</p>
  
  <p><strong>Edit</strong> from comment: </p>
  
  <p>I have been trying call this function, I'm getting a object does not support this method error:</p>
  
  <pre><code>Public Function htmlCell(id As String) As String 
      htmlCell = IE.getElementById("ctl00_ContentPlaceHolder1_gvExtract")
                      .get‌​ElementsByTagName("t‌​d")(id).innerHTML 
  End Function
  </code></pre>