title: Entering password for Windows Security while automating IE using VBA
body: <p>I am trying to scrape some data off an intranet website created by a 3rd party and send an email depending on the data.  I did this in Excel with VBA since my machine is locked down and don't have Powershell or any other scripting language.  </p>
  
  <p>The issue is the website requires a login using a Windows Security dialogue box.  I've searched for hours and nothing is working. SendKeys in VBA does not work as the security box takes over and halts VBA. This almost worked: <a href="https://stackoverflow.com/questions/24879914/vba-code-to-pass-username-password">VBA code to pass username &amp; password</a>.  </p>
  
  <p>The problem is when I scheduled it (task scheduler), sometimes the password (username is already populated) didn't go into the security dialogue and it is going to Word or whatever else is open.  I don't think "Windows Security" is the actual name of the window (though that is what is in the title).  </p>
  
  <p>Edit- Adding some of the code:</p>
  
  <pre><code>   Set IE = New InternetExplorerMedium
     IE.Visible = True
  
     CreateObject("WScript.Shell").AppActivate "XYZ.net - Internet Explorer"
  
     URL = "https://XYZ.aspx"
     IE.Navigate URL
     Do While IE.ReadyState = 4: DoEvents: Loop
     Do Until IE.ReadyState = 4: DoEvents: Loop
  
     HWNDSrc = IE.HWND
  
     SetForegroundWindow HWNDSrc
     IE.document.getElementById("overridelink").Click
  
     Application.Wait (Now + TimeValue("00:00:08"))
     Shell "WScript H:\data\excel\Logon.vbs", vbNormalFocus
  </code></pre>