Consulting

Results 1 to 4 of 4

Thread: Solved: Check if IE is running

  1. #1
    VBAX Regular
    Joined
    Nov 2005
    Posts
    30
    Location

    Solved: Check if IE is running

    Hi, first post:
    in VBA, how do I check if there's any IE-window open?

    Thanx!

  2. #2
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    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

  3. #3
    VBAX Regular
    Joined
    Nov 2005
    Posts
    30
    Location
    Worked fine, thanx for the tip!

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •