2

即使我只打开一个浏览器窗口(没有选项卡)并且只运行一个 iexplore.exe 进程,以下代码行也会返回几个 InternetExplorer 对象。如何只获取打开的浏览器窗口对象?

For Each ie As SHDocVw.InternetExplorer In shellWindows

4

1 回答 1

2

这可能会有所帮助

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
于 2011-12-18T00:51:04.187 回答