?
Solved

Unable to terminate instance of EXCEL

Posted on 2011-10-25
4
Medium Priority
?
269 Views
Last Modified: 2012-05-12
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?

0
Comment
Question by:shambalad
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37027332
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
 
LVL 12

Accepted Solution

by:
danishani earned 1600 total points
ID: 37027364
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
 
LVL 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 400 total points
ID: 37028034
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
 
LVL 7

Author Comment

by:shambalad
ID: 37028089
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question