Lesley MacMahon
New Member
Hi,
I have inherited a Progress GUI application that produces reports in Excel. There are several reports that all work fine because they produce the information in a single worksheet. My report has to take a new worksheet on change of Project. I have this working fine except that when the procedure finishes and I check the Task Manager Excel is still there. The user will want to rerun the procedure within the same session so more and more Excel processes are left hanging around. Can anyone see what I am missing from the following code:-
DEFINE VARIABLE chXL AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chXLBook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chXLSht AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE vReportName AS CHARACTER INITIAL "TestExcelReport" NO-UNDO.
DEFINE VARIABLE vName AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
CREATE "Excel.Application" chXL.
ASSIGN chXL:VISIBLE = true.
/* open Project Detail spreadsheet template */
chXL:Workbooks:OPEN("f:\gpr\templates\Project Detail.xls").
ASSIGN chXLBook = chXL:WorkBooks:ITEM(1).
DO i = 1 TO 5:
chXLBook:worksheets(1):COPY(,chXLBook:worksheets(i)).
/* select the new sheet */
chXLSht = chXLBook:worksheets(i).
ASSIGN vName = "TestSheet " + STRING(i).
chXLSht:Range("A20"):VALUE = vName.
/* give worksheet the project name */
chXLSht:NAME = "Page " + STRING(i).
END.
chXLBook:SaveAs("f:\gpr\" + vReportName + ".xls",43,,,,,).
chXL:Application:Workbooks:CLOSE() NO-ERROR.
chXL:Application:QUIT NO-ERROR.
RELEASE OBJECT chXLSht.
RELEASE OBJECT chXLBook.
RELEASE OBJECT chXL.
ASSIGN chXLSht = ?.
ASSIGN chXLBook = ?.
ASSIGN chXL = ?.
I want to use an existing Excel spreadSheet as a template because it sets up the Headings of the report.
Thanks for any help you can give,
Lesley MacMahon
I have inherited a Progress GUI application that produces reports in Excel. There are several reports that all work fine because they produce the information in a single worksheet. My report has to take a new worksheet on change of Project. I have this working fine except that when the procedure finishes and I check the Task Manager Excel is still there. The user will want to rerun the procedure within the same session so more and more Excel processes are left hanging around. Can anyone see what I am missing from the following code:-
DEFINE VARIABLE chXL AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chXLBook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chXLSht AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE vReportName AS CHARACTER INITIAL "TestExcelReport" NO-UNDO.
DEFINE VARIABLE vName AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
CREATE "Excel.Application" chXL.
ASSIGN chXL:VISIBLE = true.
/* open Project Detail spreadsheet template */
chXL:Workbooks:OPEN("f:\gpr\templates\Project Detail.xls").
ASSIGN chXLBook = chXL:WorkBooks:ITEM(1).
DO i = 1 TO 5:
chXLBook:worksheets(1):COPY(,chXLBook:worksheets(i)).
/* select the new sheet */
chXLSht = chXLBook:worksheets(i).
ASSIGN vName = "TestSheet " + STRING(i).
chXLSht:Range("A20"):VALUE = vName.
/* give worksheet the project name */
chXLSht:NAME = "Page " + STRING(i).
END.
chXLBook:SaveAs("f:\gpr\" + vReportName + ".xls",43,,,,,).
chXL:Application:Workbooks:CLOSE() NO-ERROR.
chXL:Application:QUIT NO-ERROR.
RELEASE OBJECT chXLSht.
RELEASE OBJECT chXLBook.
RELEASE OBJECT chXL.
ASSIGN chXLSht = ?.
ASSIGN chXLBook = ?.
ASSIGN chXL = ?.
I want to use an existing Excel spreadSheet as a template because it sets up the Headings of the report.
Thanks for any help you can give,
Lesley MacMahon