Sponsored Link

Sponsored Link

Monday, June 22, 2009

VBA to close excel.exe

Closing all orphan Excel.exe process

I came across this issue while I was generating reports on SQL server using MS Excel. Here we use to generate reports using MS Excel macro. However this macro's where executed via DTS in SQL. At times if any error occurs, the DTS use to close down leaving excel.exe running as orphan object. This not only sometimes prevent other excel objects but also slow downs your server performance. To tackle this we used the following code to close all MS Excel objects before opening new object.

Sub Close_Excel()

Dim strClsExl As String
strClsExl = "TASKKILL /F /IM Excel.exe"
Shell strClsExl, vbHide

End Sub

Warning: Kindly save all your work before trying above code as this will close all MS Excel instances running on computer and you will end up loosing your work.

For your convenience I have linked two files for download along with this post. One has Macro example which you can in understanding code while other is an add-in which will can directly install in your MS Excel. Also, in add-in I have let user to decide which .exe file they want to close.

Download Close Excel example

Add-ins to close exe

If you need more help with installing add-in on your computer do visit our other post which is mentioned below.

Install Add-ins help

Kindly leave your comments about this post and receive more such add-ins by subscribing us.

We assure you knowledge, not SPAM!

0 comments:

Post a Comment