2009 Dec 23 10:49 AM
Hello all,
I am using DOI to download data from SAP to excel. In the excel file a range of cells are protected with the method protect of the inteface i_ oi_spreadsheet.
Everything is working fine only unprotected cells are changeable. But after the download the users want to have possibility to change the protected cells. The excel-file is asking for a password.
In the i_oi_spreadsheet i can't find a method with password as parameter. Is it possible to set a password with DOI?
Regards,
Tony
Hello all,
I am using DOI to download data from SAP to excel. In the excel file a range of cells are protected with the method protect of the inteface i_ oi_spreadsheet.
Everything is working fine only unprotected cells are changeable. But after the download the users want to have possibility to change the protected cells. The excel-file is asking for a password.
In the i_oi_spreadsheet i can't find a method with password as parameter. Is it possible to set a password with DOI?
Regards,
Tony
2009 Dec 23 2:18 PM
solved on my own.
In DOI unprotect the columns that are editable with mehtod
call method g_handle->protect_range
exporting
name = wa_fields-fieldname
protect = ' '.
After closing the excel file use OLE to setup a password ( = sy-uname)
FORM set_password .
DATA: w_excel TYPE ole2_object,
w_workbook TYPE ole2_object,
w_worksheet TYPE ole2_object.
CREATE OBJECT w_excel 'EXCEL.APPLICATION'. "Create object for Excel
SET PROPERTY OF w_excel 'VISIBLE' = 0. "In background Mode
CALL METHOD OF w_excel 'WORKBOOKS' = w_workbook.
CALL METHOD OF w_workbook 'OPEN'
EXPORTING
#1 = p_file.
GET PROPERTY OF w_excel 'ActiveSheet' = w_worksheet.
Protect the first worksheet with a password
CALL METHOD OF w_worksheet 'PROTECT'
EXPORTING #1 = sy-uname.
Save the Excel file
GET PROPERTY OF w_excel 'ActiveWorkbook' = w_workbook.
CALL METHOD OF w_workbook 'SAVE' NO FLUSH.
CALL METHOD OF w_workbook 'CLOSE'.
CALL METHOD OF w_excel 'CLOSE'.
FREE OBJECT: w_worksheet, w_excel, w_workbook.
ENDFORM. " SET_PASSWORD
Edited by: tony pang on Dec 23, 2009 3:18 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |