Consultor Eletrônico



Kbase P19507: Page Break in Excel using OLEAutomation causes GPF
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   2/16/2007
Status: Verified

FACT(s) (Environment):

Progress 9.1C

SYMPTOM(s):

Page Break in Excel using OLEAutomation causes GPF

OleMainThreadWndName: excel.exe - Application Error

HPageBreaks:Add(<com-handle>) method causes GPF when Excel is closed

CAUSE:

Bug# 20010724-028

CAUSE:

The COM-HANDLE specified in the HPageBreaks:Add(<com-handle>) method is not released by Progress and it causes the GPF.

FIX:

Upgrade to 9.1D or later.

If upgrading is not an option, the following code resolves the problem:

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 chChart AS COM-HANDLE NO-UNDO.

/* Define a COM-HANDLE variable to store the break line rows handle*/
DEFINE VARIABLE chBreakLine AS COM-HANDLE NO-UNDO.

CREATE "Excel.Application" chExcelApplication.

ASSIGN chExcelApplication:Visible = TRUE
chWorkbook = chExcelApplication:Workbooks:Add()
chWorkSheet = chExcelApplication:Sheets:Item(1)

/*Assign the break line row handle to the variable defined above*/
chBreakLine = chWorksheet:Rows("12").

/* Pass the COM-HANDLE variable as parameter in the Add() method instead of
the whole reference to the row like: chWorksheet:Rows("12")*/
chExcelApplication:ActiveWindow:SelectedSheets:HPageBreaks:Add(chBreakLine).

/* Release the COM-HANDLES */
RELEASE OBJECT chBreakLine.
RELEASE OBJECT chExcelApplication.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chWorksheet.