IE VBA working with pop up window

When automating internet explorer it can be tricky when you have to work with pop up windows because VBA doesn’t know which IE window to be referencing.  The below VBA lets you designate which window the VBA should be running on.

Update the if statement with my_url = pop up window url or my_title = pop up window title.  Which you can find by right click -> properties.

Set objShell = CreateObject("Shell.Application")
 my_url = ""
 my_title = ""
IE_Count = objshell.Windows.Count
for x = 1 to (IE_count - 1) 
 on error resume next 
 my_url = objShell.Windows(x).document.Location 
 my_title = objShell.Windows(x).document.Title 
 if my_url like "" then 
 set objIE = objShell.Windows(x) 
 Exit For 
 End if
Next x
On error goto 0