title: Call onclick JS event on website button using VBA
body: <p>I am using VBA to interact with a website in IE. </p>
  
  <p>As part of this I need to click a button there but a simple <code>.Click</code> does not work as I need to <strong>trigger the JS onclick event behind this button</strong>. </p>
  
  <p>Can someone here tell me how I can achieve this, either by simulating the click and triggering the event or by calling the JS event directly ?  </p>
  
  <p>This should happen after the below VBA code. </p>
  
  <p><strong>My VBA code:</strong> </p>
  
  <pre><code>Dim IE As Object
  Dim MyURL As String
  Dim varResults As New DataObject
  
  varResults.SetText TxtSql.Text
  varResults.PutInClipboard
  Unload FrmResults
  
  Set IE = CreateObject("InternetExplorer.Application")
  
  MyURL = "https://myFirstUrl"
  
  IE.Navigate MyURL
  IE.Visible = True
  
  While IE.busy
      DoEvents
  Wend
  
  Application.Wait (Now + TimeValue("0:00:02")) ' to allow time for loading the page
  </code></pre>
  
  <p><strong>The onclick JS event behind the button:</strong> </p>
  
  <pre><code>javascript:document.forms.jobProfileForm.action='https://mySecondUrl';document.forms.jobProfileForm.submit()
  </code></pre>
  
  <p><strong>The button's HTML:</strong> </p>
  
  <pre><code>&lt;input class="normalbttn" id="editProfileBttn" value="Edit Profile" onclick="theAboveJS" type="button"&gt;&lt;/input&gt; 
  </code></pre>