[AccessD] Code not letting go of Excel

Hale, Jim Jim.Hale at FleetPride.com
Fri Jun 30 09:32:42 CDT 2006


try objXLApp.ActiveWorkbook
Apparently global members of the Excel application object such as
ActiveWorkbook
must be explicitly qualified with the Application object for them
to be properly destroyed when they go out of scope. Even though the program
will run correctly without them being qualified, they are not cleaned up
properly when used this way.

Jim Hale

-----Original Message-----
From: ewaldt at gdls.com [mailto:ewaldt at gdls.com]
Sent: Friday, June 30, 2006 5:25 AM
To: accessd at databaseadvisors.com
Subject: [AccessD] Code not letting go of Excel


I can't find anything wrong with this code, but Excel does not completely
close down (i.e., it shows up in Task Manager). Could someone tell me what
I'm missing, please? BTW, thanks to Duane Hookum for providing much of it;
I'm sure the error is in my part, not his.

TIA.

Thomas F. Ewald
FCS Database Manager
General Dynamics Land Systems
(586) 276-1256

-----------------------------------------------------------------------
Sub IPT_Export()
Dim objXLApp As Object
Dim objXLbook As Excel.Workbook
Dim astrLinks As Variant
Dim strFileName As String

strFileName = InputBox("What should the new file be named? ", "Request for
Information") & ".xls"

Set objXLApp = CreateObject("Excel.Application")
Set objXLApp = New Excel.Application
Set objXLbook = objXLApp.Workbooks.Open("WRI_IPT.xlt", 0)

DoCmd.SetWarnings False

objXLbook.SaveAs (strFileName)

astrLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
ActiveWorkbook.BreakLink _
        Name:=astrLinks(1), _
        Type:=xlLinkTypeExcelLinks
objXLbook.Save
objXLbook.Close

Set objXLbook = Nothing
Set objXLApp = Nothing

DoCmd.SetWarnings True

End Sub






This is an e-mail from General Dynamics Land Systems. It is for the intended
recipient only and may contain confidential and privileged information.  No
one else may read, print, store, copy, forward or act in reliance on it or
its attachments.  If you are not the intended recipient, please return this
message to the sender and delete the message and any attachments from your
computer. Your cooperation is appreciated.
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.


More information about the AccessD mailing list