How can i determine the number of IE windows currently open?
If you always do what you've always done, you will always get what you've always got!
In MSDN, under the Windows Management Interface, you'll find several snippets of code, that allow you to read metrics for every instance of a process(executable).
I use this in testing for memory leaks. Included in the data per process is the PID, the same PID as in Task Manager. Unfortunately, TP does not do well with Task Manager, thus the WMI.
Oops, WMI is Windows Management Instrumentation.
thanks for your feedback. I will have a look at the link you've provided.
Another way of doing the same would be:
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
For Each IE In SWs
…your code here…
After adding the reference for SHDocVw,
I put Msgbox "Hello" as "...your code here"
I had 2 copies of IE up and got 3 hellos,
4 copies of IE & 5 hellos. I checked Task Manager to verify my counts.
So outside of the loop I added MsgBox SWs.Count and always got N+1
Perplexed ?? Is this the way the dll is supposed to work ??
You may not know but Windows Explorer = Internet Explorer.
You need test the Document Type inside the For Each loop:
<font class="small">Code:</font><hr /><pre>
If TypeName(IE.document) <> "Nothing" Then ' overkill really
If TypeOf IE.document Is IShellFolderViewDual2 Then
' = Windows Explorer
If TypeName(IE.document) = "HTMLDocument" Or TypeName(IE.document) = "IHTMLDocument2" Then
' = Internet Explorer
That explains it,