[AccessD] Let Excel object live?

Sad Der accessd666 at yahoo.com
Fri Feb 2 04:35:58 CST 2007


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



More information about the AccessD mailing list