Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

OLE to read data from excel file

Hello,

I am using the OLE methods to read from a EXCEL file and writing the data to the clipboard. The problem that we are facing is that once the report has executed if we try and open the Excel file, it only opens in 'READ ONLY' mode.

Any ideas why this is happening?

Following is the code snippet

  • Start EXCEL

CREATE OBJECT l_excel 'excel.application'.

IF sy-subrc <> 0.

WRITE:/ 'Excel cannot be started'.

ELSE.

  • Open the file

CALL METHOD OF l_excel 'workbooks' = l_workbook.

IF sy-subrc <> 0.

WRITE:/ 'Excel cannot be started'.

ENDIF.

CALL METHOD OF l_workbook 'open'

EXPORTING

#1 = p_file1.

IF sy-subrc <> 0.

WRITE:/ 'File cannot be opened'.

ENDIF.

.........

.........

.........

call method of l_workbook 'close'

EXPORTING

#1 = 'NO'.

  • Closing application

call method of l_excel 'QUIT'.

  • Free the object

free object: l_excel,

l_sheet.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question