[AccessD] Excel zombie won't die

Michael R Mattys michael.mattys at adelphia.net
Sat Aug 30 12:22:03 CDT 2003


Jim,

Maybe Set appExcel = NEW Excel.Application
would put the app under Access' thread control,
allowing it to close the Excel app?

Michael R. Mattys
www.mattysconsulting.com



----- Original Message -----
From: "Hale, Jim" <jim.hale at fleetpride.com>
To: "'Access Developers discussion and problem solving'"
<accessd at databaseadvisors.com>
Sent: Saturday, August 30, 2003 12:57 PM
Subject: RE: [AccessD] Excel zombie won't die


> Thank you for your reply. Here is a test function I used
>
> Function test()
> Dim appExcel As Excel.Application
> Set appExcel = Excel.Application
> appExcel.Visible = True
> appExcel.Workbooks.Open _
> "C:\Documents and Settings\jhale\Application
> Data\Microsoft\Templates\PlanTemplate.xlt"
>  appExcel.ActiveWorkbook.Close SaveChanges:=False
>
> The_End:
>     appExcel.Quit
>     Set appExcel = Nothing
>
> End Function
>
> After this runs an instance of Excel can be seen in the task manager. If I
> kill it the next time I run the code it says the remote server cannot be
> found. The only way to kill it is to close Access. I thought appExcel.quit
> would shut it down. Any thoughts? This is office 2000 run under windows
2000
> prof. TIA
> Jim Hale
>
> -----Original Message-----
> From: Henry Simpson [mailto:hsimpson88 at hotmail.com]
> Sent: Friday, August 29, 2003 2:33 PM
> To: accessd at databaseadvisors.com
> Subject: Re: [AccessD] Excel zombie won't die
>
>
> 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
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


----------------------------------------------------------------------------
----


> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list