[AccessD] Let Excel object live?

sgoodhall at comcast.net sgoodhall at comcast.net
Fri Feb 2 07:39:27 CST 2007


As much as I hate globals, I think this might be a valid use.  You could make the Excel Application a global in another module, and it would stay open until you destroy it.  You will need to ensure that it gets destroyed before the application terminates, or you may end up with a zombie task.  If your user kills the application with the Windows control box, you may not be able to intercept it. Unless you make it visible, it will be hard to get rid of.

Regards,

Steve Goodhall

 -------------- Original message ----------------------
From: Sad Der <accessd666 at yahoo.com>
> 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




More information about the AccessD mailing list