Kbase P40056: ACTIVEX - How to protect a MS Excel Spreadsheet using Progress 4GL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/15/2008 |
|
Status: Verified
GOAL:
ACTIVEX - How to protect a MS Excel Spreadsheet using Progress 4GL?
GOAL:
ACTIVEX - How to make a MS Excel Worksheet read-only using Progress 4GL?
FACT(s) (Environment):
Progress 8.x
Progress 9.x
FIX:
To make a MS Excel Spreadsheet read-only, call the Protect method on the worksheet COM Object passing a password string to it as follows:
DEFINE VARIABLE chExcelApp AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorksheet AS COM-HANDLE NO-UNDO.
CREATE "Excel.Application":U chExcelApp.
chExcelApp:VISIBLE = TRUE.
chExcelApp:WorkBooks:ADD().
chWorksheet = chExcelApp:Worksheets("Sheet1":U).
chWorksheet:Cells(1,1) = "Spreadsheet Protection Test".
chWorksheet:Cells(1,1):ColumnWidth = 25.
NO-RETURN-VALUE chWorksheet:Protect("test":U /* password */).
NO-RETURN-VALUE chWorksheet:SaveAs("protected.xls":U).
NO-RETURN-VALUE chExcelApp:QUIT().
IF VALID-HANDLE(chWorksheet) THEN
RELEASE OBJECT chWorksheet.
IF VALID-HANDLE(chExcelApp) THEN
RELEASE OBJECT chExcelApp.