Using Excel to close other applications

PinpointJimbo

New Member
Joined
Aug 1, 2007
Messages
10
Hi,

I was wondering if there is a simple macro that can close other applications open in Windows, leaving Excel the only app open?

Cheers
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try this;

Code:
Sub Test()
    Dim Prog As Object
    Dim objWMIService As Object
    Dim RunningProcesses As Object
    Dim strComputerName As String
    Dim strNameSpace As String
    Dim strClassName As String

    strComputerName = "."
    strNameSpace = "root\cimv2"
    strClassName = "win32_process "
    
    On Error Resume Next
    If Err.Number <> 0 Then
        MsgBox "WMI is not installed! Code will be terminated...", vbExclamation, _
             "Windows Management Instrumentation"
        Exit Sub
        On Error GoTo 0
    End If
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputerName & _
                        "\" & strNameSpace)
    Set RunningProcesses = objWMIService.ExecQuery("Select * from " & strClassName)
    For Each Prog In RunningProcesses
        If Not LCase(Prog.Name) Like "excel*" Then Prog.terminate
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,358
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top