title: How to fill webform
body: <p>I want to update the fields in website using Excel values.</p>
  <p>I found this macro online and tried to edit it.</p>
  <p>How do I update fields once login is successful?</p>
  <p>I have added following references:</p>
  <ul>
  <li>Microsoft HTML Object Library</li>
  <li>Microsoft Internet controls</li>
  </ul>
  <p>I tried running it in IE8.</p>
  <p>Received error:</p>
  <blockquote>
  <p>Method 'Document' of object 'IWebBrowser2' failed on line</p>
  </blockquote>
  <p>I updated to IE11 and now the error is:</p>
  <blockquote>
  <p>&quot;Automation error, unspecified error&quot;</p>
  </blockquote>
  <p><code>IE.document.getelementsbyname(&quot;_58_login&quot;).Value = &quot;jigarjigar&quot;</code></p>
  <pre><code>Public Declare PtrSafe Function SetForegroundWindow Lib &quot;user32&quot; (ByVal HWND As Long) As Long
  
  Sub Automate_IE_Enter_Data()
      'This will load a webpage in IE
      Dim i As Long
      Dim URL As String
      Dim IE As Object
      Dim objElement As Object
      Dim objCollection As Object
      Dim HWNDSrc As Long
      Dim document As HTMLDocument
    
      'Create InternetExplorer Object
      Set IE = GetObject(&quot;new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}&quot;)
      'Set IE = CreateObject(&quot;InternetExplorer.Application&quot;)
   
      'True to make IE visible, or False for IE to run in the background
      IE.Visible = True
    
      'Navigate to URL
      IE.Navigate https://www.asite.com/login-home/
      ' Wait while IE loading...
      Do While IE.ReadyState = 4: DoEvents: Loop
        
      'Get Window ID for IE so we can set it as activate window
      HWNDSrc = IE.HWND
        
      'Set IE as Active Window
      SetForegroundWindow HWNDSrc
        
     'Find &amp; Fill Out Input Box
       
     IE.document.getelementsbyname(&quot;_58_login&quot;).Value = &quot;jigarjigar&quot;
     IE.document.getelementsbyname(&quot;_58_password&quot;).Value = &quot;mypassword&quot;
     IE.document.getelementsbyclassname(&quot;btn-submit nobgcolor&quot;).Click
     'Unload IE
  endmacro:
     Set IE = Nothing
     Set objElement = Nothing
     Set objCollection = Nothing
        
  End Sub
  </code></pre>
  <pre class="lang-html prettyprint-override"><code> &lt;table class=&quot;lfr-table&quot;&gt;
      &lt;tr&gt;
          &lt;td class=&quot;label-unm&quot;&gt;
              Login (Email)
          &lt;/td&gt;
          &lt;td&gt;
              &lt;div class=&quot;inp-login&quot;&gt;&lt;input name=&quot;_58_login&quot; type=&quot;text&quot; value=&quot;jigar@jigar.com&quot; onblur=&quot;checkforGSUser(this)&quot; autocomplete=&quot;off&quot;/&gt;&lt;/div&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class=&quot;label-pass&quot;&gt;
              Password
          &lt;/td&gt;
          &lt;td&gt;
              &lt;div class=&quot;inp-login&quot;&gt;&lt;input id=&quot;_58_password&quot; name=&quot;_58_password&quot; type=&quot;password&quot; autocomplete=&quot;off&quot; value=&quot;&quot; /&gt;&lt;/div&gt;
              &lt;span id=&quot;_58_passwordCapsLockSpan&quot; class=&quot;pwdCapsMsgSpan&quot; style=&quot;position:absolute;display:none;&quot;&gt;&lt;table width=&quot;111&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tr&gt;&lt;td class=&quot;pwdCapsBorder&quot;&gt;&lt;img src=&quot;/html/themes/asite/images/common/caps_msg_arrow.gif&quot; hspace=&quot;10&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;pwdCapsMsg&quot;&gt;&amp;#160;Caps Lock is on.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/span&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;div class=&quot;div-submit&quot;&gt;&amp;#160;&lt;/div&gt;
  &lt;div class=&quot;div-login-link&quot;&gt;
      &lt;input class=&quot;btn-submit nobgcolor&quot; type=&quot;image&quot; src=&quot;/html/themes/asite/images/common/login.gif&quot; /&gt;
      &lt;a target=&quot;_self&quot; href=&quot;https://portal.asite.com/widget/web/guest/home?p_p_id=58&amp;p_p_lifecycle=0&amp;p_p_state=normal&amp;p_p_mode=view&amp;_58_struts_action=%2Flogin%2Fview&amp;_58_cmd=forgot-password&quot;&gt;Forgot Password?&lt;/a&gt;
      &lt;br/&gt;
      &lt;a href=&quot;https://www.asite.com/contactus&quot; target=&quot;_top&quot;&gt;Don't have an account?&lt;/a&gt;
      &lt;br/&gt;
      &lt;div class=&quot;clear-all&quot;&gt;&lt;/div&gt;
      &lt;div class=&quot;clear-all&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  </code></pre>