>In various places in our application I use the following code to create an Excel object and export data:-
>
>oExcel=CREATEOBJECT("Excel.Application")
>oExcel.Workbooks.Add()
>IF UPPER(oExcel.Name)= "OBJECT"
> lHasExcel97 = .T.
> oExcel = oExcel.Sheets[1]
>ELSE
> lHasExcel97 = .F.
>ENDIF
>
>
>This works nicely if Excel is not yet running but if the user already has Excel running on his PC then this code will again invoke Excel rather than use the existing Excel application.
>
>How can I change the code to detect if Excel is already running and, if so, simply add a new Workbook to the existing Excel application.
>
Instead of CREATEOBJ(), use GETOBJECT(), which will use an existing instance of the server if it's available, or start one if it isn't:
oExcel=GETOBJECT(,'Excel.Application')