[AccessD] Let Excel object live?

Hale, Jim Jim.Hale at FleetPride.com
Fri Feb 2 11:24:32 CST 2007


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.


More information about the AccessD mailing list