title: How to login a website using VBA and retrieve data to excel?
body: <p>There are plenty of examples of how to login into a website, like gmail</p>
  
  <p>But for some reason my code only opens the webpage without logging into the target page, using the provided username and password</p>
  
  <p>I've enabled the HTML object library and Microsoft Internet Controls</p>
  
  <p>Any thoughts , as I am fairly new to this object library?</p>
  
  <p>Plus, how do I grab a table to import into excel from a website after I log in?</p>
  
  <p>I tried macro recording but it needs a password to login into the website</p>
  
  <p>An example would be helpful :) Thanks so much!</p>
  
  <pre><code>Dim HTMLDoc As HTMLDocument
  Dim MyBrowser As InternetExplorer
  
  
  Sub MyGmail()
   Dim MyHTML_Element As IHTMLElement
   Dim MyURL As String
   On Error GoTo Err_Clear
   MyURL = "https://www.google.com/accounts/Login"
  
  
   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.Email.Value = "nasterpizza87@gmail.com" 
   HTMLDoc.all.passwd.Value = "************" 'my password would be here
  
  
   For Each MyHTML_Element In HTMLDoc.getElementsByTagName(“input”)
  
        If MyHTML_Element.Type = “submit” Then _
             MyHTML_Element.Click: Exit For
  
   Next
  
  
   Err_Clear:
   If Err &lt;&gt; 0 Then
   Err.Clear
   Resume Next
   End If
  
  End Sub
  </code></pre>