[AccessD] Problem with Access VBA makes Excel Orphan

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Fri Nov 13 15:34:52 CST 2009


Edward,

I just ran your example code in this form...


Sub Excel_test(zPath As String, zName As String)
Dim ExcelApp            As Excel.Application
    Dim ExcelwBook          As Excel.Workbook

    Set ExcelApp = New Excel.Application
    Set ExcelwBook = ExcelApp.Workbooks.Add
    ExcelApp.DisplayAlerts = False
    ExcelwBook.SaveAs zPath & zName
    ExcelApp.DisplayAlerts = True
 
    ExcelwBook.Save
    ExcelwBook.Close False
    ExcelApp.Quit
 
    Set ExcelwBook = Nothing
    Set ExcelApp = Nothing
 

End Sub

... And it does NOT leave an Excel orphan around. I can only conclude from that that your problem lies with the code between  the lines. Somewhere you are probably setting a reference to some Excel object that is not subsequently released.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Edward Zuris
Sent: Friday, November 13, 2009 2:58 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Problem with Access VBA makes Excel Orphan


 Using the below code from an Access 2000 VBA  application, once running these commands there  is still an Excel job running in task manager.
 
 The Excel orphan makes it impossible to run the  VBA application recessively.
 
 One clue is Excel will finally shut down if  the Access 2000 VBA application / database  is shutdown.
 
 Any way to tell Excel to just shut down ?
 
 Is there a work-a-round for this problem ?
 
 Thanks.
 
 Sincerely,
 Edward Zuris.

 -
 
 =======================================================
 ====== .Quit code not closing Excel Application ======
 
    Dim ExcelApp            As Excel.Application
    Dim ExcelwBook          As Excel.Workbook
    . . .
    Set ExcelApp = New Excel.Application
    Set ExcelwBook = ExcelApp.Workbooks.Add
    . . .
    ExcelApp.DisplayAlerts = False
    ExcelwBook.SaveAs zPath & zName
    ExcelApp.DisplayAlerts = True
 
    ExcelwBook.Save
    ExcelwBook.Close False
    ExcelApp.Quit
 
    Set ExcelwBook = Nothing
    Set ExcelApp = Nothing
 
 =======================================================
 =======================================================
 -
 
 Yet a simpler VBA applications doesn't have  this issue using the following.
 
 This also fails using the complex VBA program.
 
 Any ideas ?
 
 =======================================================
 = .Quit code Working closing simple Excel Application =
 
    ExcelwBook.Application.DisplayAlerts = False
    ExcelwBook.SaveAs zPath & zName
    ExcelwBook.Application.DisplayAlerts = True
 
    ExcelwBook.Application.Quit
 
    ExcelApp.Quit
    
    Set ExcelwBook = Nothing
    Set ExcelApp = Nothing
 
 
 =======================================================
 =======================================================
 
 
--
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