2005 Apr 28 5:01 PM
Hi All,
I would like to save an Excel File as Password protected.
This File is created by OLE2.
How can I do this?
This is the Coding, how I save the File-->
CALL METHOD OF ls_wbook 'SaveAs' EXPORTING #1 = p_file.
Thanks for the Answers...
Bye
Besi
2005 Apr 28 11:41 PM
This will work:
REPORT YZZZZZ.
INCLUDE OLE2INCL.
DATA: oExcel TYPE OLE2_OBJECT,
oWBs TYPE OLE2_OBJECT,
oWB TYPE OLE2_OBJECT,
P_file(50) TYPE C VALUE 'C:test.xls',
P_pwd(10) TYPE C VALUE 'HELLO'.
* Start a new copy of Excel
CREATE OBJECT oExcel 'EXCEL.APPLICATION'.
* Get list of workbooks, initially empty
CALL METHOD OF oExcel 'Workbooks' = oWBs.
* Add a new workbook, keep a reference to it
CALL METHOD OF oWBs 'Add' = oWB.
* Set password for Excel file
SET PROPERTY OF oWB 'Password' = P_pwd.
* Save file
CALL METHOD OF oWB 'SaveAs' EXPORTING #1 = P_file
2005 Apr 29 11:11 AM
Hi Juan,
It did not work. If I set this Coding-->
SET PROPERTY OF oWB 'Password' = P_pwd.
,the Excel File will not be saved.
Bye
Besi
2005 Apr 29 12:09 PM
Hello Besi,
The following code should work. Try it out.
CALL METHOD OF document 'Protect' EXPORTING
#1 = 2
#2 = -1
#3 = 'password'.
CALL METHOD OF documents 'Save'.
Here 'document' is the 'ActiveDocument' object.
How to get the 'document' object:
CREATE OBJECT worddoc 'Word.Document'.
GET PROPERTY OF worddoc 'Application' = wordapp.
GET PROPERTY OF wordapp 'ActiveDocument' = document.
Regards,
Jitendar