title: "Click" a javascript button with VBA
body: <p>endless googling and lots of solutions haven't seemed to help. I keep getting endless errors of different kinds, and just can't find an elegant way of clicking this button unless I get the code to wait for four seconds while I click it manually with my mouse. </p>
  
  <p>It works on other buttons, but I'm working if the problem here is the nested doPostBack and the many '' (substituted from "") in it? </p>
  
  <p>Code below (I've trimmed out irrelevant sections)</p>
  
  <p>VBA Code:</p>
  
  <pre><code>Sub IE_Clicks()
  
      Dim shellWins As ShellWindows
      Dim IE As InternetExplorer
  
      Set shellWins = New ShellWindows
  
      If shellWins.Count &gt; 0 Then
      ' Get IE
      Set IE = shellWins.Item(0)
      IE.Visible = True
      Else
      ' Create IE
      Set IE = New InternetExplorer
      IE.Visible = True
      End If
  
      IE.Navigate ("[URL]")
  
  Do While (IE.Busy Or IE.READYSTATE &lt;&gt; READYSTATE.READYSTATE_COMPLETE)
      DoEvents
  Loop
      Call IE.document.parentWindow.execScript("WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$cphMain$btnAddTab', '', true, '', '', false, false))", "JavaScript")
  
      Set IE = Nothing
   End Sub
  </code></pre>
  
  <p>HTML Code: </p>
  
  <pre><code>&lt;input type="submit" name="ctl00$cphMain$btnAddTab" value="Add New" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;ctl00$cphMain$btnAddTab&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, false))" id="ctl00_cphMain_btnAddTab" class="ActionButton"&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var theForm = document.forms['aspnetForm'];
  if (!theForm) {
      theForm = document.aspnetForm;
  }
  function __doPostBack(eventTarget, eventArgument) {
      if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
          theForm.__EVENTTARGET.value = eventTarget;
          theForm.__EVENTARGUMENT.value = eventArgument;
          theForm.submit();
      }
  }
  //]]&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Something that would enable me to click this button would be amazing. </p>