[AccessD] Excel zombie won't die

Henry Simpson hsimpson88 at hotmail.com
Fri Aug 29 14:33:16 CDT 2003


It looks like you aren't giving us the entire picture.  Presumably you 
created a workbook object?  I generally count my Object variables in the 
procedure and make sure that each Set statement has a matching Set x = 
Nothing in the error handler, and I make sure there is an On Error Resume 
Next as the first line after the Label that marks the exit routine.

In Access/Excel 97, using the following code that mirrors your use of the 
only object variable you show, the instance of Excel is created and 
destroyed without any problem:

Sub ExTst()
Dim x As Excel.Application
Set x = Excel.Application

x.Visible = True
Msgbox "Pause Here"
x.Quit
Set x = Nothing
End Sub

If I were you, I would look for Dim statements beginning with the word 
'Excel.' as varaiables pointing to Workbook, Sheet, Range, Cell or other 
Excel objects (or late bound objects that point to Excel objects) that are 
not properly destroyed will prevent Excel from closing.  If you have no such 
object variables, I would explicitly create at least Workbook and WorkSheet 
objects and destroy those, in reverse order of their creation.

Hen

>From: "Hale, Jim" <jim.hale at fleetpride.com>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: "'Accessd (E-mail)" <accessd at databaseadvisors.com>
>Subject: [AccessD] Excel zombie won't die
>Date: Fri, 29 Aug 2003 11:39:17 -0500
>
>  I have an instance of Excel that I can't seem to kill except through the
>task manager or shutting down Access. I can make the instance visible and
>try to shut it down using exit off the file menu but it won't shut down 
>that
>way either. The code executes without error. The code is below. What am I
>missing? TIA
>Jim Hale
>
>Public Function Load_History(intDept As Integer, strDeptname As String, _
>intCo As Integer, strRegioncode As String, strRegionName As String, _
>strAreacode As String, strDept2 As String, strPlGroup As String) As Boolean
>
>dim appExcel As Excel.Application
>Set appExcel = Excel.Application
>
>........... tons of astounding code, yada,yada,yada
>
>
>If strPW <> "none" Then 'set password
>      For i = 1 To .Sheets.Count
>         .Worksheets(i).Protect Password:=strPW
>     Next i
>         .Sheets("instruc").Unprotect Password:=strPW
>         .Sheets("assumptions").Unprotect Password:=strPW
>     End If
>     .ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
>Scenarios:=True
>     .ActiveWorkbook.Protect Structure:=True, Windows:=False,
>Password:=strPWworkbook
>     .ActiveWorkbook.SaveAs FileName:=strFileSave
>     .ActiveWorkbook.Close SaveChanges:=True
>   End With
>
>  Load_History = True
>The_End:
>
>     appExcel.Quit
>     Set appExcel = Nothing
>dbs2.Close
>
>Exit Function
>
>Err_CreatePlan:
>Load_History = False
>     MsgBox Err.Description
>     Resume The_End
>End Function
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail



More information about the AccessD mailing list