Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- 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.
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