title: Handle Pop-Up While Navigating with IE
body: <p>I have an Excel VBA macro that</p>
  <ol>
  <li>opens IE,</li>
  <li>navigates to the Medicare website,</li>
  <li>logs me in,</li>
  <li>compares the claims listed on the website with those already in the workbook</li>
  <li>alerts me to any differences</li>
  </ol>
  <p>It is during the log-in step that I have a problem, so I've reproduced that portion of the code below.  As soon as the <code>.click</code> line is executed a pop-up window appears asking the user to click the <kbd>OK</kbd> button in order to proceed.  Macro execution is suspended until I manually click the <kbd>OK</kbd>  button on the pop-up.</p>
  <p>The source code behind the <a href="http://www.mymedicare.gov" rel="nofollow noreferrer">http://www.mymedicare.gov</a> web page has information relative to the pop-up, but I haven't been able to figure out how to use it so that I can programmatically click the pop-up <kbd>OK</kbd> button.</p>
  <p>Any help in terms of figuring out how to programmatically click the pop-up's <kbd>OK</kbd> button would be much appreciated.</p>
  <blockquote>
  <p>note: For the purpose of this question, any user id and password can be used. If you handle the pop-up you'll be passed to a page that says something like incorrect user id / password.</p>
  <p>That will indicate that you've been successful in handling the pop-up.</p>
  </blockquote>
  <pre><code>Sub Medicare_Claims()' 
  ' Update the status bar 
    Application.StatusBar = &quot;Running the Medicare Claims subroutine&quot; 
  
  ' Open the &quot;MyMedicare web page 
      Set ie = CreateObject(&quot;InternetExplorer.Application&quot;) 
      With ie 
          .Visible = True 
          .Navigate &quot;https://www.mymedicare.gov/&quot; 
      End With 
  
  ' Loop until the page is fully loaded 
      Do Until ie.ReadyState = 4 And Not ie.Busy 
          DoEvents 
      Loop 
      
  ' Log-in 
      ie.Document.all.Item(&quot;ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName&quot;).Value = &quot;abcde&quot;           
      ie.Document.all.Item(&quot;ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword&quot;).Value = &quot;12345&quot;     
      ie.Document.getElementById(&quot;ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn&quot;).Click
       
  ' Loop until the page is fully loaded 
      Do Until ie.ReadyState = 4 And Not ie.Busy 
          DoEvents 
      Loop 
  
      Application.Wait (Now + TimeValue(&quot;0:00:15&quot;)) 
  
  ' Navigate further to the Search Claims&quot; web page 
      ie.Navigate &quot;https://www.mymedicare.gov/searchclaims.aspx&quot; 
  </code></pre>