title: Find button from onclick attribute and click
body: <p>I'm using VBA and stuck on a way to trigger a <strong>Download</strong> button in <em>HTML PAGE</em> which inspects below codes:</p>
  
  <pre><code>&lt;input onClick="javascript:__dopostback('GridView1','Accountnumber$0')" type="button" value="Download"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>More than one <strong>Download button</strong> exists on this page and I want to click on the first one.</p>
  
  <p><a href="https://i.stack.imgur.com/egws2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/egws2.png" alt="enter image description here"></a></p>
  
  <p>In these elements the unique <em>Attribute</em> is:</p>
  
  <pre><code>"OnClick=javascript:__dopostback('GridView1','Accountnumber$0')"
  </code></pre>
  
  <p>But I don't know how to trigger with below VBA:</p>
  
  <pre><code>On Error GoTo Err_Clear
   myURL = "Enter your url"
   Set MyBrowser = New InternetExplorer
   MyBrowser.Silent = True
   MyBrowser.Navigate myURL
   MyBrowser.Visible = True
   Do
   Loop Until MyBrowser.ReadyState = READYSTATE_COMPLETE
   Set htmlDoc = MyBrowser.Document
   htmlDoc.all.txtAccNo.Value = ""
   htmlDoc.all.ddlReasons.Value = ""
   htmlDoc.all.txtRequester.Value = "" 
   htmlDoc.all.txtMobNo.Value = ""
   htmlDoc.all.txtLandLine.Value = ""
   htmlDoc.all.txtEmailAdd.Value = ""
   htmlDoc.all.ddlRelation.Value = ""
   htmlDoc.all.button1.Click
  
   '**OnClick event required here **
  
   htmlDoc.getElementsByXpath("input[type=""button""]")(0).Click  '&lt;--(Not Working)
  
   Err_Clear:
   If Err &lt;&gt; 0 Then
   Err.Clear
   Resume Next
   End If 
  </code></pre>