View Single Post
  #3 (permalink)  
Old September 29th, 2006, 06:46 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, I left in some error checking code. Here is the code you should use:

Dim sComputer

sComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel = impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")
For Each objProcess in colProcesses
    If objProcess.Name = "EXCEL.EXE" Then
           errReturnCode = objProcess.Terminate()
       End If
Next


mmcdonal
Reply With Quote