Click to See Complete Forum and Search --> : excel won't quit


maysenp
August 2nd, 2001, 11:49 PM
I am accessing an excel spread sheet via a vb command button. I update one or more of the fields and then when data exchange is complete using the following function: to close excel
Problem is that Excel still stays active. I checked by doing an Ctl+Alt+Del and it is still in the tasks window. What am I forgetting to close.

[vbcode]
Function Close_applications()
xlApp.AlertBeforeOverwriting = False
xlApp.ActiveWorkbook.Save
'close app here
xlApp.ActiveWorkbook.Close
Clipboard.Clear
EMPLOYEEFOUND = False
xlApp.Quit
Set xlApp = Nothing
End Function
[\vbcode]

Cimperiali
August 3rd, 2001, 02:28 AM
xlapp.Workbooks.Close
will close all workbooks and not only the one active (you sure you have only one?)
Set xlapp = Nothing 'after here excell should disappear from tasks if all references have been released.



Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

maysenp
August 3rd, 2001, 10:40 PM
I tried xlApp.Workbooks.Close
like you suggested still no luck. I'm wondering whether excel is the problem. even when I press end task it may take 5 or 6 seconds before i'm asked to confirm. And Yes I only have 1 sheet in my workbook. thanks for the suggestion anyway..any one else have any solutions.

Cimperiali
August 6th, 2001, 09:56 AM
If you are performing long tasks (ie: do while...loop) or if you've imported lots of data, it may be. However, ther's a chance you referenced some other object of excell and did not close/release them. have a look at your code for "set something = somethingElse" (and optionally: "something.open") and a lack of a correspondent (optionally: "something.close" and) "set something = nothing".
Hope this helps

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Alejandro Ochoa
August 6th, 2001, 01:21 PM
'after the sentence

xlApp.ActiveWorkbook.Close

'you have to put
xlApp.Quit ' this will close excel
set xlApp = nothing