I've been working on an Excel VBA macro that automates several tasks on the Medicare website. The macro opens IE, logs in, compares claims, and alerts me to any differences found. However, I've encountered a problem during the log-in step, specifically when dealing with a pop-up window that requires manual interaction.
The code snippet below highlights the issue:
After executing the .click
line, a pop-up appears, prompting the user to click the OK button to proceed. Unfortunately, this halts the execution of the macro until I manually intervene by clicking the OK button on the pop-up.
I've checked the source code of the webpage for information on handling the pop-up automatically, but haven't had any luck so far.
If anyone can provide guidance on programmatically clicking the pop-up's OK button, it would be greatly appreciated.
Note: Any dummy user id and password can be used for testing. If you manage to handle the pop-up correctly, you'll be redirected to a page indicating invalid credentials.
This will confirm that you've successfully resolved the pop-up issue.
Sub Medicare_Claims()'
' Update the status bar
Application.StatusBar = "Running the Medicare Claims subroutine"
' Open the "MyMedicare web page
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "https://www.mymedicare.gov/"
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("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName").Value = "abcde"
ie.Document.all.Item("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword").Value = "12345"
ie.Document.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn").Click
' Loop until the page is fully loaded
Do Until ie.ReadyState = 4 And Not ie.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:15"))
' Navigate further to the Search Claims" web page
ie.Navigate "https://www.mymedicare.gov/searchclaims.aspx"