Consultor Eletrônico



Kbase P26708: ACTIVEX - Microsoft Excel process still in memory after closing it when using Hyperlinks.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/5/2004
Status: Unverified

FACT(s) (Environment):

Progress 9.1C

SYMPTOM(s):

Microsoft Excel process still in memory after closing the Progress Application

Hyperlinks are used by the application.

Quit method is correctly used.

CAUSE:

Hyperlinks:Add method causes Excel process to be in memory after closing it.
This has been identified as Bug# 20010724-028 fixed in Progress 9.1D.

FIX:

The COM-HANDLE specified in the Hyperlinks:Add method is not released by Progress and so the process is in memory even after the Excel is correctly closed. A code like this will not release the Process in 9.1C


DEFINE VARIABLE chExcelApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkBook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkSheet AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chHyperlink AS COM-HANDLE NO-UNDO.

CREATE "Excel.Application" chExcelApplication.

ASSIGN chExcelApplication:Visible = TRUE
chExcelApplication:DisplayAlerts = FALSE.
chWorkBook = chExcelApplication:Workbooks:Add.
chWorkSheet = chExcelApplication:Sheets:Item(1).

ASSIGN chWorkSheet:Range("A1"):Value = "Hyperlink From Cell"
chWorkSheet:Range("A30"):Value = "Hyperlink To Cell".

chHyperlink = chWorkSheet:Hyperlinks:Add(chWorkSheet:Range("A1"),
"",
"'Sheet1'!A30",
"Hyperlink From Cell",
"Hyperlink From Cell").

chWorkBook:CLOSE().
chExcelApplication:QUIT().

RELEASE OBJECT chHyperlink.
RELEASE OBJECT chWorkSheet.
RELEASE OBJECT chWorkBook.
RELEASE OBJECT chExcelApplication.


The following code instead resolves the problem by defining the Hyperlink range in an another Object and releasing it explicitly (/**/ are the lines added or modified) :


DEFINE VARIABLE chExcelApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkBook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkSheet AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chHyperlink AS COM-HANDLE NO-UNDO.

CREATE "Excel.Application" chExcelApplication.
ASSIGN chExcelApplication:Visible = TRUE
chExcelApplication:DisplayAlerts = FALSE.

chWorkBook = chExcelApplication:Workbooks:Add.
chWorkSheet = chExcelApplication:Sheets:Item(1).
ASSIGN chWorkSheet:Range("A1"):Value = "Hyperlink From Cell"
chWorkSheet:Range("A30"):Value = "Hyperlink To Cell".

/* Here there are the changes: */
DEFINE VARIABLE chRange AS COM-HANDLE NO-UNDO.
chRange = chWorkSheet:Range("A1").

chHyperlink = chWorkSheet:Hyperlinks:Add(chRange,
"",
"'Sheet1'!A30",
"Hyperlink From Cell",
"Hyperlink From Cell").
PAUSE.

chWorkBook:CLOSE().
chExcelApplication:QUIT().

/*Now just release the object*/
RELEASE OBJECT chRange.

RELEASE OBJECT chHyperlink.
RELEASE OBJECT chWorkSheet.
RELEASE OBJECT chWorkBook.
RELEASE OBJECT chExcelApplication.