2011-09-13 7 views
2

次のコード行は、1つのブラウザウィンドウ(タブなし)と1つのiexplore.exeプロセスのみを実行していても、いくつかのInternetExplorerオブジェクトを返します。開いているブラウザのウィンドウオブジェクトを取得するにはどうすればよいですか?SHDocVw.InternetExplorerあまりにも多くのオブジェクトを返すシェルウィンドウ

For Each ie As SHDocVw.InternetExplorer In shellWindows

+1

に役立つことがあります。動作することができるのは、IEインスタンスに対してのみ動作するmshtml.IHtmlDocumentにie.Documentをキャストしようとすることです。 –

答えて

2

これは、あなたはまた、開いているすべてのWindowsエクスプローラのウィンドウを取得します

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 
関連する問題