How to Kill Excel Processes With VBA

Updated July 20, 2017

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:

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

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

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

bibliography-icon icon for annotation tool Cite this Article

About the Author

Jaime Avelar is a professional writer whose programming articles appear on various websites. He has been a software programmer since 2000. Avelar holds a Master of Science in information systems from the University of Texas at Arlington.