title: Clicking button in internet explorer
body: <p>I have form which I would like to open IE window, navigate to specific web page, input some data, click the submit button and capture results.</p>
  
  <p>I have been stuck at clicking the submit button part for days and search multiple forums for answer but no luck. The reason I believe is because it's not a true button and does not have a name tag or id I can reference </p>
  
  <p>The site that I am accessing is <a href="http://trulos.com/mileage/" rel="nofollow noreferrer">http://trulos.com/mileage/</a></p>
  
  <p>inspect code from chrome for the button</p>
  
  <p> Calculate Mileage</p>
  
  <p>I can input the Origin address and Destination address but just can not figure out how to click the "Calculate mileage button.</p>
  
  <p>Sample code I am working with</p>
  
  <pre><code>Dim frominput As String
  Dim toinput As String
  frominput = "Stockton, CA"
  toinput = "Lubbock, TX"
  Dim ele As Object
  
  
  Dim IE As Object
  Set IE = CreateObject("internetexplorer.application")
  IE.navigate "http://trulos.com/mileage/"
  IE.Visible = True
  
  While IE.busy
      DoEvents
  Wend
  Pause (2)
  
  
  
  
  
  
  IE.Document.all("from").Value = frominput
  IE.Document.all("to").Value = toinput
  'IE.Document.Forms(0).submit
  'IE.Document.all("button:Calculate Mileage").Click
  'IE.Document.all("btnG").Click
  
  
  'IE.Document.getElementsByTagName("button")(0).Click
  'Set ele = IE.Document.getElementsByClassName("Panel-Body")(0)
  'MsgBox ele.classname
  
  
  
  '&lt;button type="button" onclick="get_addresses();" class="btn btn-default"&gt; Calculate Mileage&lt;/button&gt;
  'MsgBox IE.Document.body.innertext
  'MsgBox IE.Document.getElementsByClassName("btn btn-default")
  
  
  'Set the_input_elements = IE.Document.getelementsbytagname("input")
  'For Each input_element In the_input_elements
  'If input_element.getattribute("class") = "btn btn-default" Then
  '    input_element.Click
  '    Exit For
  'End If
  'Next input_element
  
  
  
  'Set tags = IE.Document.getElementsByTagName("button")
  Set tags = IE.Document.getElementsByClassName("btn btn-default")
  For Each tagx In tags
      If tagx.innertext = "submit" Then
          tagx.Click
          Exit For
      End If
  MsgBox tagx.innertext
  Next
  </code></pre>