Hi, first post:
in VBA, how do I check if there's any IE-window open?
Thanx!
Hi, first post:
in VBA, how do I check if there's any IE-window open?
Thanx!
Courtesy of Ivan F Moala's coding skill.
[VBA]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[/VBA]
Justin Labenne
Worked fine, thanx for the tip!
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!
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables