Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VB.NET VBA script
Can anyone tell me why if I manually open instances of IE the Running Object Table (ROT) has registers all instances but if I use vb scripting to open instances of IE only the first instance is registered on the ROT
 
Is there any way to fix this????
 
Thks
 

The example: is a console app it count the instances of IE and their names opens 3 IE instance are generated but count = 1 but count should = 3
 
If I manually open IE then all manual opened instances are counted.
 
Imports System.Threading.Thread
Imports System.Text.RegularExpressions
Imports SHDocVw
Imports mshtml
 
Module Module1
Dim objIE As InternetExplorer = Nothing
Dim objIE11 As InternetExplorer = Nothing
Dim objIE21 As InternetExplorer = Nothing
Sub Main()
 

objIE = CreateObject("InternetExplorer.Application")
 
objIE.Navigate("http://www.google.com.au")
objIE.Visible = True
 
While objIE.Busy = True
Sleep(1000)
End While
 
Dim blnFoundSubmit As Boolean = False
Do
Dim a
For Each a In objIE.Document.GetElementsByTagName("A")
If a.innerText = "News" Then
blnFoundSubmit = True
Exit For
End If
Next
If blnFoundSubmit Then
a.Click() ' NOTE: allow pop-ups...
Sleep(2000)
Else
Sleep(200)
End If
Loop Until blnFoundSubmit
 
objIE11 = CreateObject("InternetExplorer.Application")
 
objIE11.Navigate("http://ninemsn.com.au/")
objIE11.Visible = True
 
While objIE11.Busy = True
Sleep(1000)
End While
 
objIE21 = CreateObject("InternetExplorer.Application")
 
objIE21.Navigate("http://au.yahoo.com/")
objIE21.Visible = True
 
While objIE21.Busy = True
Sleep(1000)
End While
 
Do
ScanIEWindows()
 
Threading.Thread.Sleep(2000)
 
ScanIEWindows()
 
Threading.Thread.Sleep(2000)
Loop
Console.ReadLine()
End Sub
 
Public Sub ScanIEWindows()
Dim windows As New SHDocVw.ShellWindows()
 
Console.WriteLine(windows.Count)
 
For Each window As SHDocVw.InternetExplorer In windows
Console.WriteLine(window.LocationName)
Console.WriteLine(window.LocationURL)
Next
End Sub
 
End Module 
 

Posted 6-Oct-11 18:07pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Therez an interesting CodeProject article to capture running IE instances. Ref: Capturing the Running IE Instances in C#[^]
 
Apparently, those instances can be registered later.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you're talking about those three CreateObject lines in your code, the count should be 1, not 3. You're not launching 3 seperate instances of an IE process. You're creating instances of a COM server which will only show up once to dole out your instances.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

ok thks dave
 
Can you tell me how to script so it is an instance or what code I would need to capture lets say the ie window title of the yahoo page
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 7 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100