title: How to call onClick with VBA in HTML code?
body: <p>How can I call <code>onClick</code> in a HTML page?</p>
  <p>Using Google, I got this code:</p>
  <pre><code>&lt;img src=&quot;Imagens/lupa.gif&quot; alt=&quot;Pesquisar Pasta&quot; class=&quot;img&quot; onclick=&quot;localizar();&quot;&gt;
  </code></pre>
  <p>I'm using this VBA code:</p>
  <pre><code>Sub FazerLoginSite()
  
  Dim IE As Object
  Set IE = CreateObject(&quot;InternetExplorer.application&quot;)
  With IE
      .Visible = True
      .Navigate (&quot;https://webseal.itau/j146/pjuridico/&quot;)
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
      On Error Resume Next
      .document.getElementById(&quot;username&quot;).Focus
      .document.getElementById(&quot;username&quot;).Value = &quot;987268556&quot;
  
      .document.getElementById(&quot;password&quot;).Focus
      .document.getElementById(&quot;password&quot;).Value = &quot;&quot;
  
      .document.All(&quot;button1&quot;).Click
      On Error GoTo 0
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
  
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
      .document.getElementById(&quot;pasta&quot;).Focus
      .document.getElementById(&quot;pasta&quot;).Value = &quot;140200586125&quot;
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
     
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
      Set allInputs = IE.document.getElementsByTagName(&quot;input&quot;)
      For Each element In allInputs
          If element.getAttribute(&quot;src&quot;) = &quot;Imagens/lupa.gif&quot; Then
              element.invokemember (&quot;OnClick&quot;)
              Exit For
          End If
      Next element
      While .Busy Or .ReadyState &lt;&gt; 4: DoEvents: Wend
  
      Debug.Print .LocationURL
  End With
  
  End Sub
  </code></pre>
  <p>How can I click on this code? In the web site this is an Image and the first part of the code I set my login and password, the I put a number to search, here called &quot;Pasta&quot;, and finally I'm trying to click on this image.</p>