Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Get ALL The Opened Internet Explorer (IE) using Microsoft Excel

To Get all the already opened Inter­net Explorer s(IE) using Microsoft Excel, say for exam­ple you sev­eral IE tabs are opened and you want to get all the infor­ma­tion like their HWND prop­erty, URLs and Title.

Steps:

  • Cre­ate the object of Shell Application
  • Get all the win­dows using shellobject.Windows
  • Nav­i­gate all the windows
  • check if win­dow is Inter­net Explorer
  • Get HWND prop­erty of Inter­net Explorer
  • Get Title of Inter­net Explorer
  • Get URL of Inter­net Explorer

Cre­ate the object of Shell Appli­ca­tion

Set objShell = CreateObject(“Shell.Application”)

Get all the win­dows using shellobject.Windows

Set objAll­Win­dows = objShell.Windows

Nav­i­gate all the windows

For Each ow In objAllWindows

check if win­dow is Inter­net Explorer

If (InStr(1, ow, “Inter­net Explorer”, vbTextCom­pare)) Then

Get HWND prop­erty of Inter­net Explorer

ow.Hwnd

Get Title of Inter­net Explorer

ow.Document.Title

Get URL of Inter­net Explorer

ow.locationURL

Com­plete Code:

Sub getALLBrowsers()
    Dim mainWorkBook As Workbook
    i = 2
    
    Set objShell = CreateObject("Shell.Application")
    Set objAllWindows = objShell.Windows
    Set mainWorkBook = ActiveWorkbook
    
    For Each ow In objAllWindows
        If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
            mainWorkBook.Sheets("browsers").Range("A" & i) = ow
            mainWorkBook.Sheets("browsers").Range("B" & i) = ow.Hwnd
            mainWorkBook.Sheets("browsers").Range("C" & i) = ow.Document.Title
            mainWorkBook.Sheets("browsers").Range("D" & i) = ow.locationURL
            i = i + 1
            'MsgBox ow.Hwnd & "  " & ow & "   " & ow.locationURL & "  " & ow.Document.Title
        End If
    Next
End Sub
Internet Explorer

Inter­net Explorer

All Opened IE Browser Informations

All Opened IE Browser Informations

 

You may also like...

3 Responses

  1. Ross says:

    I know this thread is a bit old, but I have mod­i­fied your code to retrieve URLs from mul­ti­ple open tabs in IE. How­ever this issue I’m hav­ing is that when I get the URLs from the IE tabs, they’re not in the order that the IE Tabs were opened. Is there any­way to acti­vate a spe­cific tab to make sure I’m return­ing the URLs in cor­rect order?

  2. Ross says:

    Sub GetURLs()

    Requires ref­er­ence to Microsoft Inter­net Con­trols
    Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer
    Dim Count As Inte­ger
    Dim NewURL As String

    Count = 2

    Estab­lish link to IE appli­ca­tion
    Set SWs = New SHDocVw.ShellWindows

    For Each vIE In SWs

    If vIE.LocationURL = “” Then

    Else

    Sheet1.Cells(Count, 2) = vIE.LocationURL
    Count = Count + 1

    End If

    Next

    Set SWs = Noth­ing
    Set vIE = Nothing

    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: