title: VBA / IE: How to use VBA to click a button on a website
body: <p>I am new to VBA and hope someone here can help me with the following: </p>
  
  <p>I would like to use VBA to open a website and then click two different buttons on this website.</p>
  
  <p><strong>My challenges with this are:</strong><br>
  1) How can I tell the code to wait until the webpage is fully loaded so that I can make sure the button that I want to click is actually visible ?<br>
  2) How do I address the button correctly using it's unique ID ?</p>
  
  <p><strong>My code so far:</strong> </p>
  
  <pre><code>Dim varResults As New DataObject
  Dim varButtonID As String
  Dim i As Long
  Dim objIE As Object
  Dim objElement As Object
  Dim objCollection As Object
  
  varResults.SetText TxtSql.Text
  varResults.PutInClipboard
  
  ' assign button ID
  varButtonID = "Oracle_setExplainOptionsSpan"
  
  ' create IE object
  Set objIE = CreateObject("InternetExplorer.Application")
  
  With objIE
      .navigate "https://myURL"
      .Visible = True
  End With
  
  While objIE.ReadyState &lt;&gt; 4: Wend
  
  objIE.document.getElementById(varButtonID).Click
  </code></pre>
  
  <p>Many thanks in advance for any help with this, 
  Mike</p>