Mike Clark
Member
Progress 9.1E v2 GUI under windows
Hi
We have developed for one of our users a program that creates a .CSV file and then emails it (using SMTPmail) to their customers – this works fine.
What the user now wants is to have a ‘pure’ Excel .XLS file with set formats and column widths produced instead, and then auto emailed.
I know how to create the Excel file in Progress (I can even give it a ‘saveas’ file name) but this leaves the file open on the screen. (see part example below)
Is there any way, in Progress, to force the Excel file to ‘close’ without user intervention??
I have tried various CLOSE(), QUIT() statements but with no luck.
Any help would be gratefully accepted
Mike Clark
DEFINE VARIABLE chExcelApplication AS COM-HANDLE.
DEFINE VARIABLE chWorkbook AS COM-HANDLE.
DEFINE VARIABLE chWorksheet AS COM-HANDLE.
DEFINE VARIABLE chChart AS COM-HANDLE.
DEFINE VARIABLE chWorksheetRange AS COM-HANDLE.
DEFINE VARIABLE iColumn AS INTEGER INITIAL 2 NO-UNDO.
DEFINE VARIABLE cColumn AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRange AS CHARACTER NO-UNDO.
DEFINE VARIABLE savename AS CHAR FORMAT "x(50)" INITIAL "testxl.xls" NO-UNDO.
DEFINE VARIABLE cashdesc AS CHAR FORMAT "x(40)" NO-UNDO.
OS-DELETE VALUE(savename).
PAUSE 0 NO-MESSAGE.
/*
To produce xl version
*/
/* create a new Excel Application object */
CREATE "Excel.Application" chExcelApplication.
/* launch Excel so it is not visible to the user */
chExcelApplication:Visible = FALSE.
chExcelApplication:ScreenUpdating = FALSE.
/* create a new Workbook */
chWorkbook = chExcelApplication:Workbooks:Add().
/* get the active Worksheet */
chWorkSheet = chExcelApplication:Sheets:Item(1).
/* set the column names for the Worksheet */
chWorkSheet:Columns("A"):ColumnWidth = 4. /* P/M */
chWorkSheet:Columns("B"):ColumnWidth = 40. /* Description */
/* rest of widths defined here */
/* chWorkSheet:Range("A1:I1"):Font:Bold = TRUE. */
chWorkSheet:Range("A1"):Value = "Z-Read Till".
chWorkSheet:Range("A2"):Value = "P/M".
/* rest of coulns defined here */
/* formats, currencies for columns etc
chWorksheet:COLUMNS(3):NumberFormat = "#,###,##0".
*/
DEF VAR xchar AS CHAR FORMAT "x(80)" NO-UNDO.
DEF VAR xx AS INT NO-UNDO.
FOR EACH cashup NO-LOCK:
FIND ana-codes WHERE ana-codes.ana-code = cashup.ana-code AND
ana-code.ana-type = "PM" NO-LOCK NO-ERROR.
IF AVAIL ana-codes THEN cashdesc = ana-codes.DESCRIPTION.
ELSE cashdesc = "UNKNOWN PAYMENT METHOD".
iColumn = iColumn + 1.
cColumn = STRING(iColumn).
cRange = "A" + cColumn.
chWorkSheet:Range(cRange):Value = Cashup.ana.
cRange = "B" + cColumn.
chWorkSheet:Range(cRange):Value = Cashdesc.
/* rest of spread sheet set up here */
END.
chExcelApplication:Visible = TRUE.
chExcelApplication:ScreenUpdating = TRUE.
chWorkSheet:Range("A2:A2"):Select().
IF savename NE "" THEN
chWorkbook:SaveAs(savename,-4143,,,,,,,TRUE).
/* release com-handles */
RELEASE OBJECT chExcelApplication.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chWorksheet.
/*
RELEASE OBJECT chWorksheetRange.
*/
Hi
We have developed for one of our users a program that creates a .CSV file and then emails it (using SMTPmail) to their customers – this works fine.
What the user now wants is to have a ‘pure’ Excel .XLS file with set formats and column widths produced instead, and then auto emailed.
I know how to create the Excel file in Progress (I can even give it a ‘saveas’ file name) but this leaves the file open on the screen. (see part example below)
Is there any way, in Progress, to force the Excel file to ‘close’ without user intervention??
I have tried various CLOSE(), QUIT() statements but with no luck.
Any help would be gratefully accepted
Mike Clark
DEFINE VARIABLE chExcelApplication AS COM-HANDLE.
DEFINE VARIABLE chWorkbook AS COM-HANDLE.
DEFINE VARIABLE chWorksheet AS COM-HANDLE.
DEFINE VARIABLE chChart AS COM-HANDLE.
DEFINE VARIABLE chWorksheetRange AS COM-HANDLE.
DEFINE VARIABLE iColumn AS INTEGER INITIAL 2 NO-UNDO.
DEFINE VARIABLE cColumn AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRange AS CHARACTER NO-UNDO.
DEFINE VARIABLE savename AS CHAR FORMAT "x(50)" INITIAL "testxl.xls" NO-UNDO.
DEFINE VARIABLE cashdesc AS CHAR FORMAT "x(40)" NO-UNDO.
OS-DELETE VALUE(savename).
PAUSE 0 NO-MESSAGE.
/*
To produce xl version
*/
/* create a new Excel Application object */
CREATE "Excel.Application" chExcelApplication.
/* launch Excel so it is not visible to the user */
chExcelApplication:Visible = FALSE.
chExcelApplication:ScreenUpdating = FALSE.
/* create a new Workbook */
chWorkbook = chExcelApplication:Workbooks:Add().
/* get the active Worksheet */
chWorkSheet = chExcelApplication:Sheets:Item(1).
/* set the column names for the Worksheet */
chWorkSheet:Columns("A"):ColumnWidth = 4. /* P/M */
chWorkSheet:Columns("B"):ColumnWidth = 40. /* Description */
/* rest of widths defined here */
/* chWorkSheet:Range("A1:I1"):Font:Bold = TRUE. */
chWorkSheet:Range("A1"):Value = "Z-Read Till".
chWorkSheet:Range("A2"):Value = "P/M".
/* rest of coulns defined here */
/* formats, currencies for columns etc
chWorksheet:COLUMNS(3):NumberFormat = "#,###,##0".
*/
DEF VAR xchar AS CHAR FORMAT "x(80)" NO-UNDO.
DEF VAR xx AS INT NO-UNDO.
FOR EACH cashup NO-LOCK:
FIND ana-codes WHERE ana-codes.ana-code = cashup.ana-code AND
ana-code.ana-type = "PM" NO-LOCK NO-ERROR.
IF AVAIL ana-codes THEN cashdesc = ana-codes.DESCRIPTION.
ELSE cashdesc = "UNKNOWN PAYMENT METHOD".
iColumn = iColumn + 1.
cColumn = STRING(iColumn).
cRange = "A" + cColumn.
chWorkSheet:Range(cRange):Value = Cashup.ana.
cRange = "B" + cColumn.
chWorkSheet:Range(cRange):Value = Cashdesc.
/* rest of spread sheet set up here */
END.
chExcelApplication:Visible = TRUE.
chExcelApplication:ScreenUpdating = TRUE.
chWorkSheet:Range("A2:A2"):Select().
IF savename NE "" THEN
chWorkbook:SaveAs(savename,-4143,,,,,,,TRUE).
/* release com-handles */
RELEASE OBJECT chExcelApplication.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chWorksheet.
/*
RELEASE OBJECT chWorksheetRange.
*/