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

Cannot save file and close application using winword 2007

Former Member
0 Likes
732

Hi Experts,

We have a custom report that creates an MS Word file as an output. By the end of the report we need to save the MS Word file then close the MS Word application. We are able to successfully save and close in MS Word 2003 using the method below.

**********************

CALL METHOD OF wordobj 'FileSaveAs'

EXPORTING

#1 = zfilename.

CALL METHOD OF wordobj 'FileExit'.

*************************

Why are these methods not working when using MS Word 2007? Please help.

Thanks so much.

-Vlad

Hi Experts,

We have a custom report that creates an MS Word file as an output. By the end of the report we need to save the MS Word file then close the MS Word application. We are able to successfully save and close in MS Word 2003 using the method below.

**********************

CALL METHOD OF wordobj 'FileSaveAs'

EXPORTING

#1 = zfilename.

CALL METHOD OF wordobj 'FileExit'.

*************************

Why are these methods not working when using MS Word 2007? Please help.

Thanks so much.

-Vlad

4 REPLIES 4
Read only

Former Member
0 Likes
680

Hi,

Have a look at the below link

KR

Veeranji Reddy P.

Read only

0 Likes
680

Hi,

The questions in the thread you showed is also not answered. They are also not able to make he SaveAs method work correctly.

Read only

0 Likes
680

Have you tried the below?

I just found an amazing program by Y.SAITA at erpgenie.com.

While it appears I've clobbered something in my code snippet above by opening the workbook,
Y.SAITA's program data comes from the clipboard and the following works:

h_workbook type ole2_object, "WORKBOOK

cos_saveas type sychar32 value 'SaveAs',
cos_xlworkbook type i value -4143, "*.xls


call function 'FLUSH'
exceptions
cntl_system_error = 1
cntl_error = 2
others = 3.
if sy-subrc = 0.
call method of h_workbook cos_saveas
exporting
#1 = p_file
#2 = cos_xlworkbook.
endif.
(further error checking)


Also, all the other Excel-related methods carry the 'no flush' option.

I'm so confused, but now can do what I needed to.

Still appreciate more of your thoughts, however.

Anyways, if you get to know the answer please share.

KR

Veeranji Reddy P.

Read only

0 Likes
680

Hi,

We have found the solution! The issue is not a programming error. Upon further investigations, it was found that read/write permissions by the Windows user is affecting the 'FileSaveAs' method. You need to make sure that the Windows user generating the report has the permission to save files in the specified folder (file path).

Thanks!