Heenan, Lambert
Lambert.Heenan at AIG.com
Fri Feb 2 12:42:48 CST 2007
Can I ask *why* you want to keep the Excel object live? What are you going to do to it after the form closes? Whatever you want to do, I doubt that it would be at all difficult to simply reopen the Excel file after you form closes, and (quite correctly) destroys the Excel object. Lambert -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Friday, February 02, 2007 12:25 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Let Excel object live? How about if you put your code in a module and call it from a form. Jim Hale -----Original Message----- From: Sad Der [mailto:accessd666 at yahoo.com] Sent: Friday, February 02, 2007 4:36 AM To: Acces User Group Subject: [AccessD] Let Excel object live? Hi group, I've got a form that opens an Excel template and fills it with data. I've got the following line: Private objXL As cExcel this is a 'form level variabel'. When the user presses the 'export button' this line is called (on click event): Set objXL = New cExcel In the initiate of this Class I call a function that checks if there is an Excel instance: If objExcel Is Nothing Then Set ExcelObject = CreateObject("Excel.Application") Else 'do nothing, object already alive End If So at this point I have a form. In the properties of the form there is an objXL. When I close the form: DoCmd.Close acForm, Me.Name, acSaveNo The Excel object (objXL) is destroyed and thus the terminate event is triggered. This event closes/kills the object and Excel itself is closed. How can I keep this object alive and still close the form? Maybe not closing the form but hiding it? But how do I hide the form and when opening the form first check if it's open? Regards, Sander ____________________________________________________________________________ ________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -- 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. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com