Consultor Eletrônico



Kbase P28176: How to do SaveAs in MS Excel without to be prompted for file override ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

How to do SaveAs in MS Excel without to be prompted for file override ?

GOAL:

How to use a progress character variable when call MS Excel SaveAs method

FIX:

To don't be prompted for file override, before calling SaveAs excel method you should delete eventually already existing file or you can set the chExcel:DisplayAlerts = FALSE .


Down here is an example:


DEFINE VARIABLE chExcel AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorksheet AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkbook AS COM-HANDLE NO-UNDO.
def var cMyNewFile as char no-undo init "d:\MyPersonalNewExcelFilexx.xls".
def var cFileToDelete as char no-undo.

CREATE "excel.application" chExcel connect no-error.
if error-status:num-messages > 0 then
CREATE "excel.application" chExcel.

/* Open an Excel document */
chExcel:Workbooks:Add.
chExcel:visible = yes.

/* Add a new workbook */
chWorkbook = chExcel:Workbooks:Add().

/* delete eventually existing file*/
os-command silent del value(cMyNewFile).
/*OR*/
chExcel:DisplayAlerts = FALSE.

/*SaveAs*/
chWorkbook:SaveAs(cMyNewFile,,,,,,).


/* Quit Excel */
/*chExcel:quit().*/

/* Release Com-handle */

RELEASE OBJECT chWorkbook.
RELEASE OBJECT chExcel.