Excel processes still running after program ends

obio

New Member
progress 9.1D

Hi,

I've got a procedure than produces an excel report. At the end of this program the excel processes are still running. Now the code below shows how I create and release my com objects.

Code:
CREATE "Excel.Application" chExcelApplication.

chExcelApplication:Visible = FALSE.

chWorkbook = chExcelApplication:Workbooks:Add().

chWorkSheet = chExcelApplication:Worksheets(1).

chBorder = chWorkSheet:Range("A2").

/* do some stuff with the borders */

chBorder = chWorkSheet:Range("B2").

/* do some stuff with the borders */


/* release com-handles */

IF VALID-HANDLE(chBorder) THEN RELEASE OBJECT chBorder.
IF VALID-HANDLE(chWorksheet) THEN RELEASE OBJECT chWorksheet.
IF VALID-HANDLE(chWorkbook) THEN RELEASE OBJECT chWorkbook.
IF VALID-HANDLE(chExcelApplication) THEN RELEASE OBJECT chExcelApplication.      


ASSIGN
    chBorder = ?
    chWorksheet = ?
    chWorkbook = ?
    chExcelApplication = ?.

Now I'm pretty sure I've got the order right when it comes to releasing the com objects.
What I'm not sure about is the fact that I'm creating several chBorder objects and releasing only one? Could that be the problem? If it is a problem is there a simple way of releasing multiple chBorder objects without hard-coding it?
 

RKR

Member
Hi,

The release of a com object does not mean that the application will be stopped. It only frees up resources used by Progress. To quit excel you should enter the following line, just before you start to release all the objects.

chExcelApplication:quit().

This method stops excel from running.


obio said:
progress 9.1D

Hi,

I've got a procedure than produces an excel report. At the end of this program the excel processes are still running. Now the code below shows how I create and release my com objects.


Code:
CREATE "Excel.Application" chExcelApplication.

chExcelApplication:Visible = FALSE.

chWorkbook = chExcelApplication:Workbooks:Add().

chWorkSheet = chExcelApplication:Worksheets(1).

chBorder = chWorkSheet:Range("A2").

/* do some stuff with the borders */

chBorder = chWorkSheet:Range("B2").

/* do some stuff with the borders */


/* release com-handles */

IF VALID-HANDLE(chBorder) THEN RELEASE OBJECT chBorder.
IF VALID-HANDLE(chWorksheet) THEN RELEASE OBJECT chWorksheet.
IF VALID-HANDLE(chWorkbook) THEN RELEASE OBJECT chWorkbook.
IF VALID-HANDLE(chExcelApplication) THEN RELEASE OBJECT chExcelApplication.      


ASSIGN
    chBorder = ?
    chWorksheet = ?
    chWorkbook = ?
    chExcelApplication = ?.

Now I'm pretty sure I've got the order right when it comes to releasing the com objects.
What I'm not sure about is the fact that I'm creating several chBorder objects and releasing only one? Could that be the problem? If it is a problem is there a simple way of releasing multiple chBorder objects without hard-coding it?
 

obio

New Member
Thanks for that but I have that bit in my code. Before l release the com objects I have these statements:

Code:
chExcelApplication:DisplayAlerts = FALSE.

chWorkbook:SaveAs (vFileName,,,,,,).

chExcelApplication:Workbooks:CLOSE(vFileName).

chExcelApplication:QUIT().

/* release com-handles */

With that excel process still hangs around.
 

obio

New Member
I've mananged to sort out my own problem.

Because I was creating more than one chBorder objects, I was just releasing one. So I basically cut it down to one chBorder object and the excel processes seem to have dissapeared!
 
Top