Open Internet Explorer if closed

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi Guys,
I use this code to check if IE11 is open or not, If its open, then bring it to front, otherwise open the default IE11 with preset home pages. What the code should be to open it.

VBA Code:
Sub CheckIE7()
    If ProcessIsRunning("iexplore.exe") Then
       MsgBox ("IE's open")
       Call Module9.OpenCurrentIE9
              
        Else
       MsgBox ("IE's closed")
       "WHAT IS THE CODE TO OPEN IE WITH HOME PAGES"
        
    End If
End Sub

Function ProcessIsRunning(strProcess As String)
    Dim objList As Object
    Set objList = GetObject("winmgmts:") _
        .execquery("select * from win32_process where name='" & strProcess & "'")
    If objList.Count > 0 Then
        ProcessIsRunning = True
    Else
        ProcessIsRunning = False
    End If
End Function










Private Declare PtrSafe Function ShowWindow Lib "user32" ( _
   ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare PtrSafe Function SetActiveWindow Lib "user32" ( _
   ByVal hwnd As Long) As Long


Sub OpenCurrentIE9()

    Dim sw As Object, IE As Object
    Set sw = CreateObject("Shell.Application").Windows
    
    For Each IE In sw
        'distinguish Internet Explorer from Windows Explorer
        If InStr(UCase(IE.FullName), "\IEXPLORE.EXE") <> 0 Then
            
            ShowWindow IE.hwnd, 3
            SetActiveWindow IE.hwnd
        End If
       Next
  
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
To just launch IE? Would this not do what you need?
VBA Code:
Shell "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top