cancel
Showing results for 
Search instead for 
Did you mean: 

OLE to read data from excel file

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member

Hi aviroop,

1. This happens bcos the instance of excel

is still there in the front-end.

(but its not visible)

2. if you press CtrlAltDel

to see the processes,

u will be able to see it.

3. Delete this instance / kill this instance

and then u will be able to open the file

again, in write mode also.

4. Closing application

call method of l_excel 'QUIT'.

  • Free the object

free object: l_excel,

l_sheet.

Unfortunately, the above code, manytimes

does not kill the excel instance.

5.*********************

To close the instance of excel,

a. Closing application

call method of l_excel 'QUIT'.

b. Free the object

free object: l_excel, l_sheet.

<b>c. FREE ALL OTHER OBJECTS ALSO if u have declared them,

viz cells, ranges, worksheet, workbook ,application</b>

regards,

amit m.

graghavendra_sharma
Contributor
0 Kudos

Hi,

Can you please send me all the methods related to excel file reading and creating using OLE.

Thanks in advance

Raghav

former_member188685
Active Contributor
0 Kudos

Hi,

Regards

vijay

Former Member
0 Kudos

HI

GOOD

AS PER YOUR REQUIREMENT I HOPE THERE WONT BE ANY MISTAKE IN YOUR CODE,WHAT YOU HAVE TO DO IS WHILE OPENING THE EXCEL FILE WHEN IT IS ASKING FOR READ ONLY MODE CLICK ON NO,OR SEE WHEATHER YOU HAVE ALREADY OPEN THE SAME EXCEL FILE.

THANKS

MRUTYUN