title: VBA Clicking on an Item with Internet Exporer
body: <p>My company uses a web based reporting system and I'm trying to automatically export the data to Excel. There is a standard dropdown menu with File > Export to XLS and I would like to automatically click the "Export" button to download the report.</p>
  
  <p>I have read through other posts dealing with clicking buttons to expand a page, or enter a value into a form, etc, but possibly because the button is in a drop down menu, or because the element is within an <code>iframe</code> none of the previously posted solutions have worked for me.</p>
  
  <p>So Far:</p>
  
  <ul>
  <li>I can navigate to the page</li>
  <li>I can get the <code>menuExportXLS</code> element</li>
  <li><code>Debug.print</code> prints the correct <code>innerText</code></li>
  <li>My code is not throwing any errors</li>
  </ul>
  
  <p><strong>BUT I can't successfully click the button to download the file.</strong></p>
  
  <p>Alternatively, there is a javascript <code>onclick</code> script within the HTML that could trigger the download, but I don't know how to call it in VBA. I would be happy to get either method running.</p>
  
  <p><a href="https://i.stack.imgur.com/a43C8.png" rel="nofollow noreferrer">Sample of HTML</a></p>
  
  <pre><code>Sub ExportXLSTest()
  
  Dim appIE As InternetExplorerMedium
  Dim Obj As Object
  
  Set appIE = New InternetExplorerMedium
  sURL = "https://Site"
  
  With appIE
      .Navigate sURL
      .Visible = True
  End With
  
  Do While appIE.Busy Or appIE.ReadyState &lt;&gt; 4
      DoEvents
  Loop
  
  Application.Wait (Now + TimeValue("0:00:05"))
  
  Set Obj = appIE.document.getElementsByTagName("iframe")(0).contentDocument.getElementById("menuExportXLS")
  Debug.Print Obj.innerText
  Obj.Click
  
  Set appIE = Nothing
  
  End Sub
  </code></pre>