How to Kill Excel Processes With VBA

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Kill Excel Processes With VBA
End processes using Visual Basic for Applications. (Comstock/Comstock/Getty Images)

In computer programming, it's good practice to release all objects from memory when you're done using them to make sure running processes are not left running in the background. Excel processes may stay active when you're programming using the Microsoft Excel Object Library, and Excel application objects are not released. In VBA you can use the "Shell" function to execute "Taskkill" to forcefully end an Excel process.

Skill level:
Moderately Easy

Other People Are Reading


  1. 1

    Launch Microsoft Word, click the "Developer" tab, and click "Visual Basic." Click the "Insert" menu and click "Module" to add a new VBA code module.

  2. 2

    Create a new sub procedure by typing the following code:

    Private Sub killExcelProcess()

  3. 3

    Declare a new variable and define the Excel process:

    Dim xlsProcess As String

    xlsProcess = "TASKKILL /F /IM Excel.exe"

  4. 4

    Type the following line of code to kill the Excel process:

    Shell xlsProcess, vbHide
  5. 5

    Finish the procedure by typing "End Sub." Press "F5" to run the procedure.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.