title: VBA Click Through Website Menu
body: <p>I want to create some VBA to extract information from a website. I found the information in the HTML, but I believe it's only shown/populated in the HTML source when certain buttons are clicked on the page. I've been trying to use getElementsByTagName to perform the clicks but it has not worked so far. My code so far is to try for the second click straight away:</p>
  
  <pre><code>Sub googlesearch()
      Set objIE = CreateObject("InternetExplorer.Application")
      WebSite = "MyLink"
  
      With objIE
          .Visible = True
          .navigate WebSite
          Do While .Busy Or .readyState &lt;&gt; 4
              DoEvents
          Loop
  
  Set elems = .getElementsByTagName("button")
      For Each e In elems
  
          If (e.getAttribute("id") = "show-history") Then
              e.Click
              Exit For
          End If
  
      Next e
  
  End With
  
   Set ie = Nothing
  
  End Sub
  </code></pre>
  
  <p>I get Run Time error 438, the object doesn't support property or method.</p>
  
  <p>The code for the element I want to click first is:</p>
  
  <pre><code>&lt;button class="btn btn-lg btn-trigger other-actions-btn" id="otherActionsButton" aria-haspopup="true" type="button" data-qa="toggle-other-actions" olive-menu-initialized="true" olive-menu-trigger="otherActionsMenu" olive-menu-position="below right" olive-menu="otherActionsMenu"&gt;Other Actions&lt;/button&gt;
  </code></pre>
  
  <p>The code for the second button is:</p>
  
  <pre><code>&lt;button class="item button-link" type="button" data-qa="show-history" data-action="show:history"&gt;View History&lt;/button&gt;
  </code></pre>
  
  <p>There seems to be a lag sometimes between the page loading and all the elements being clickable because of something happening in the background, I'm not sure if this would be causing an issue?</p>
  
  <p>Any thoughts welcome!</p>
  
  <p>James</p>