The following line of code return several InternetExplorer objects even though I have only one browser window open (no tabs) and only one iexplore.exe process running. How do I only get the open browser window object?
For Each ie As SHDocVw.InternetExplorer In shellWindows
This may help
Dim objShellWindows As New SHDocVw.ShellWindows
Dim rVal As SHDocVw.InternetExplorer
For Each rVal In objShellWindows
Debug.Print TypeName(rVal.Document)
If TypeName(rVal.Document) = "HTMLDocument" Then
If rVal.Name = "Windows Internet Explorer" Then
rVal.Visible = False
rVal.Visible = True
Set ie = rVal
ie.Quit
Set ie = Nothing
End If
End If
Next rVal