none
how we get the reference to current open internet explorer using vba RRS feed

All replies

  • Sub fncMain()
        Dim appIE As Object 'InternetExplorer
        
        Set appIE = fncGetIE
        appIE.Navigate "http://www.ambienteoffice.com.br"
    End Sub
    
    Function fncGetIE() As Object 'InternetExplorer
        Dim appShell As Variant
        Dim varWindows As Variant
        Dim var As Variant
        Dim Temp As Object 'InternetExplorer
            
        Set appShell = CreateObject("Shell.Application")
        Set varWindows = appShell.Windows()
        
        On Error Resume Next
        For var = 0 To varWindows.Count - 1
            If InStr(LCase(varWindows.Item(var).FullName), "iexplore.exe") > 0 Then
                Set Temp = varWindows.Item(var)
                Exit For
            End If
        Next var
        On Error GoTo 0
        
        If Temp Is Nothing Then
            Set Temp = CreateObject("InternetExplorer.Application")
        End If
        Temp.Visible = True
        
        Set fncGetIE = Temp
    End Function


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Wednesday, January 8, 2014 10:59 PM