PDA

View Full Version : Solved: Check if IE is running



ulfal028
11-23-2005, 03:15 AM
Hi, first post:
in VBA, how do I check if there's any IE-window open?

Thanx!

Justinlabenne
11-23-2005, 05:39 AM
Courtesy of Ivan F Moala's coding skill.

Option Explicit
Sub GetNumberOfEXCELProcessesRunning()

Dim strComputer As String

Dim objWMIService As Object

Dim objProcess As Object

Dim objList As Object



'Const XL As String = "EXCEL.EXE"
Const XL As String = "IEXPLORE.EXE"
'//

strComputer = "."



Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")



Set objList = objWMIService.execquery("select * from win32_process where name='" & XL & "'")

'Set objList = objWMIService.execquery("select * from win32_process where name='EXCEL.EXE'")



MsgBox "Number of " & XL & " instances:= " & objList.Count



'// Do something like ....

'For Each objProcess In objList

' objProcess.terminate

'Next



Set objWMIService = Nothing

Set objList = Nothing

Set objProcess = Nothing



End Sub

ulfal028
11-23-2005, 06:46 AM
Worked fine, thanx for the tip!

Zack Barresse
11-23-2005, 07:56 AM
I'll go ahead and mark this as Solved for you. In the future, you can mark your own threads as Solved by going to Thread Tools | Mark Thread Solved | Perform Action.

Take care!