Navigate all opened IE in shellwindows

0

I have opened 2 Ie in load event

    Dim Start As New ProcessStartInfo
    Dim Windows As New ShellWindows ' ShellWindowsClass
    Dim Count = Windows.Count
    Start.FileName = "iexplore.exe"
    Start.Arguments = "-private -nomerge  " & "https://www.yahoo.com"
    If WindowState = ProcessWindowStyle.Hidden Then
        Start.WindowStyle = ProcessWindowStyle.Minimized
    Else
        Start.WindowStyle = WindowState
    End If
    Dim nos As Integer

    nos = 2

    For i = 1 To nos
        Process.Start(Start)
    Next
    Application.DoEvents()
    Threading.Thread.Sleep(1000)
    For Each ie In New ShellWindows

        If ie.LocationURL.Length < 1 Or InStr(ie.LocationURL, "yahoo.com") > 1 Then 
            ie.ToolBar = False
            ie.StatusBar = True
           ie.AddressBar = False
            ie.MenuBar = False
        End If
        Application.DoEvents()
    Next

this code are fine will open 2 Ie windows next how can I navigate both windows to google.com

I'm trying this codes Dim ie As InternetExplorer For Each ie In New ShellWindows If InStr(ie.LocationURL, "yahoo.com") > 1 Then ie.Navigate("http://www.google.com) End If

I'm getting this error

The requested resource is in use. (Exception from HRESULT: 0x800700AA) Next

vb.net
visual-studio-2010
internet-explorer-9
asked on Stack Overflow Jan 9, 2015 by Faran Saghar • edited Sep 5, 2017 by Cœur

1 Answer

0

ShellWindows itself is a collection so you do not need to create new instances of a collection while reiterating thru the for loop.

Your Windows object variable will hold the collection of the open windows that belong to the shell

Change your code to instead:

For Each ie In Windows
answered on Stack Overflow Jan 9, 2015 by Roman Canlas

User contributions licensed under CC BY-SA 3.0