Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Excel Sheet

Former Member
0 Likes
333

I am using the methods from the Type-Pool OLE2 to open an excel sheet and Modify it.

And this the code I am using to save the file.

CALL METHOD OF H_EXCEL 'ActiveWorkbook' = H_MAPL.

CALL METHOD OF H_MAPL 'SaveAs' EXPORTING #1 = FNAME.

CALL METHOD OF H_MAPL 'Close'.

CALL METHOD OF H_EXCEL 'Quit'.

Now i want to replace an existing file with the new data. When I save it in the background I donot want the prompt

saying that "The file already exists in the location.Do you want to replace it?"

I want it to directly replace it.Can someone tell me how to do that?

Thank You,

Shashi Devi.

2 REPLIES 2
Read only

Former Member
0 Likes
310

Hi,

Best way to do this is delete the file and then download new one.

I know function module: GUI_DELETE_FILE works absolutely fine in foreground for this task.

You just have to provide complete file path and it will delete file from your PC.

What I am not sure is if this FM will work in background as this is 'GUI'.

But you can find similar FM in SE37 with 'star FILE star DELETE'.


IF sy-batch = 'X'.
CALL FUNCTION 'GUI_DELETE_FILE'
  EXPORTING
    file_name       = 'C:\CUST1.XLS'
* EXCEPTIONS
*   FAILED          = 1
*   OTHERS          = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.

Reward if this helps.

thnx,

ags.

Read only

Former Member
0 Likes
310

Thanks for the help.