Unable to terminate instance of EXCEL

I am running a procedure that updates workbooks from Excel.
After I save and close the workbook, I execute the following to terminate the instance of Excel:

On Error Resume Next
xlsApp.DisplayAlerts = False
xlsApp.Quit
Set xlsApp = Nothing
On Error GoTo 0
On Error GoTo ErrorHandler

Nothing happens.
I watch my Task Manager display as each of the above commands execute. There is only one instance of Excel in the stack, and nothing changes.
This is more than a little annoyance for me. I have another procedure which is trying to create an ADO connection object to an Excel workbook, and it won't work if there's an instance of Excel running.
How do I kill this beast?

LVL 7
shambaladAsked:
Who is Participating?
 
danishaniCommented:
Very drastic, but this works:
Sub Kill_Excel()

Dim sKillExcel As String

sKillExcel = "TASKKILL /F /IM Excel.exe"
Shell sKillExcel, vbHide

End Sub

resource: http://vbadud.blogspot.com/2009/05/kill-residual-excel-process-using-vba.html

Hope this helps,
Daniel
0
 
mbizupCommented:
That part of your code looks okay...

Can you post the entire function?  You need to ensure that those steps get executed at any exit point in the function (not necessarily just at the end)
0
 
Patrick MatthewsCommented:
We really need to see the whole procedure.

My guess is that you have other Excel object variables, such as for range(s), worsheet(s), workbook(s), etc., and that those object variables are not being destroyed properly.
0
 
shambaladAuthor Commented:
Tried to award points and make a comment at the same time.....
Matthew - I think you are probably right about some objects not being properly destroyed. I will be looking at that in the near future.
In the meantime, though, Daniel's procedure really works like a charm.
Thanks to all
Todd
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.