How to Kill Excel Processes With VBA


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.

  • 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.

  • Create a new sub procedure by typing the following code:

    Private Sub killExcelProcess()

  • Declare a new variable and define the Excel process:

    Dim xlsProcess As String

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

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

    Shell xlsProcess, vbHide
  • Finish the procedure by typing "End Sub." Press "F5" to run the procedure.

Related Searches


  • Photo Credit Comstock/Comstock/Getty Images
Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!