dfsdttfhgj
Printable View
dfsdttfhgj
You need to explicitly 'Close' the instance of Excel. All you have done (in your example) is destroyed the Object you created :)
So try: objExcel.Close
then destroy objExcel
You need to set the sheet to nothing, close the workbook, set the workbook to nothing, quit the application, and then set the application to nothing.
In that order:
VB Code:
Set ExlSheet = Nothing ExlWorkBook.Close SaveChanges:=False Set ExlWorkBook = Nothing ExlAppTemp.Quit Set ExlAppTemp = Nothing Exit Sub
You are only setting the Excel Object to nothing if you close it there.
You should set it to nothing regardless. Put the duplicated code after the if statemnt. It won't hurt to set it to nothing twice.
Follow the steps above with everything.
Here is a module I use to close my apps.
VB Code:
Option Explicit Private Sub Command1_Click() Dim frm As Form Dim obj As Object For Each frm In Forms If frm.Name <> Me.Name Then ' Unload this form LAST For Each obj In frm On Error Resume Next Unload obj Set obj = Nothing Next Unload frm Set frm = Nothing End If Next On Error Resume Next For Each obj In frm Unload obj Set obj = Nothing Next Set frm = Nothing Unload Me End Sub
There may be a problem with your IsAppOpen function. Do you really need to use this? Can you post the code for it?
This will not work with Excel objects as it is more used for VB variable objects. ;)Quote:
Originally Posted by dglienna
Without seeing all your Excel code we can not determine what your leaving open. You MUST close and destroy all Excel objects and quit and destroy the application(s) object(s) in order to release all references to Excel and allow it to close. ;)
I have never had a problem qoing a myExcel.Quit function then setting all my excel objects to nothing. The program closes just fine and I think I am getting all of my resources back. Am I wrong? I know that Excel closes when I do this without issue.
It may close fine and not show in the taskmanager but I do believe that the references would still be resident and not relase all your resources. ;)
Edit: Moved to Office Development Forum.
To close without saving....
myExcel.DisplayAlerts = False
myExcel.Quit
then set objects = Nothing
Instead of .DisplayAlerts you could do the same thing with setting the .Saved property of the workbook to True in order to bypass the prompt. ;)
Hey guys ! I am not getting the solution.
I need ur help guys!
I am trying this :
I have also tried many other things:
Once i write the following code i think excel should go from the taskbar..
is there any thing which i might have done because of which it might not be going?
Code:
ObjExcel.Quit
Set ObjExcel = Nothing