Application Development 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: 

SaveAs in OLE

Former Member
0 Kudos

I try to save as a document, in rtf format, it is imposible.

Can you tell anything about?

REPORT zole_tutor_example_ms_word .

*--Include for OLE-enabling definitions

INCLUDE ole2incl .

DATA: v_wordapp TYPE ole2_object,

v_worddoc TYPE ole2_object,

v_wordadoc TYPE ole2_object,

v_wordcont TYPE ole2_object,

v_wordsel TYPE ole2_object,

v_wordfind TYPE ole2_object,

v_wordrep TYPE ole2_object,

v_wordbook TYPE ole2_object,

v_wordtables TYPE ole2_object,

v_wordrange TYPE ole2_object,

v_wordtext TYPE ole2_object,

v_wordstyle TYPE ole2_object.

START-OF-SELECTION .

  • Abre Word

create object v_wordapp 'word.application'.

  • Lo pone en visible

set property of v_wordapp 'Visible' = 1.

  • Cogemos el objeto documento

call method of v_wordapp 'Documents' = v_worddoc.

call method of v_worddoc 'Open'

exporting

#1 = 'c: empdocum.doc'.

call method of v_wordapp 'ActiveDocument' = v_wordadoc.

call method of v_wordadoc 'Content' = v_wordcont.

call method of v_wordadoc 'SaveAs'

exporting

#1 = 'c: empmaod.rtf'

#2 = 'wdFormatRTF'.

  • #2 = 'wdFormatWebArchive'.

  • #3 = 0

  • #4 = ''

  • #5 = 1

  • #6 = ''

  • #7 = 0

  • #8 = 0

  • #9 = 0

  • #10 = 0

  • #11 = 0 .

FREE OBJECT v_wordapp .

when i save a word document the macro give me the next information.

ActiveDocument.SaveAs

FileName:="maod.rtf"

FileFormat:= wdFormatRTF

LockComments:=False

Password:=""

AddToRecentFiles:= True

WritePassword:=""

ReadOnlyRecommended:=False

EmbedTrueTypeFonts:= False

SaveNativePictureFormat:=False

SaveFormsData:=False

SaveAsAOCELetter:=False

But in abap it does not work, Service.sap.con give not me any solution.

¿Could any answer me?

Tank you again.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

> call method of v_wordadoc 'SaveAs'

> exporting

> #1 = 'c:\temp\maod.rtf'

> #2 = 'wdFormatRTF'.

You must not use the constant names (wdFormatRTF), you must use their integer values. You'll get it by debugging any VBA macro, and use the Watch to see its value (6).


call method of v_wordadoc 'SaveAs'
exporting
#1 = 'c:\temp\maod.rtf'
#2 = 6.

Just a remark about your code:

> call method of v_worddoc 'Open'

> exporting

> #1 = 'c:\temp\docum.doc'.

>

> call method of v_wordapp 'ActiveDocument' = v_wordadoc.

You can simplify it:


call method of v_worddoc 'Open' 
= v_wordadoc "<== add the return variable after method name
exporting
#1 = 'c:\temp\docum.doc'.

> Service.sap.con give not me any solution.

For OLE, you'll never find any note (except for big bugs), here that's just consulting

3 REPLIES 3

andreas_mann3
Active Contributor
0 Kudos

look <a href="http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/204d1bb8-489d-2910-d0b5-cdddb3227820">here in this pdf of Serder</a>

grx

Andreas

Sandra_Rossi
Active Contributor
0 Kudos

> call method of v_wordadoc 'SaveAs'

> exporting

> #1 = 'c:\temp\maod.rtf'

> #2 = 'wdFormatRTF'.

You must not use the constant names (wdFormatRTF), you must use their integer values. You'll get it by debugging any VBA macro, and use the Watch to see its value (6).


call method of v_wordadoc 'SaveAs'
exporting
#1 = 'c:\temp\maod.rtf'
#2 = 6.

Just a remark about your code:

> call method of v_worddoc 'Open'

> exporting

> #1 = 'c:\temp\docum.doc'.

>

> call method of v_wordapp 'ActiveDocument' = v_wordadoc.

You can simplify it:


call method of v_worddoc 'Open' 
= v_wordadoc "<== add the return variable after method name
exporting
#1 = 'c:\temp\docum.doc'.

> Service.sap.con give not me any solution.

For OLE, you'll never find any note (except for big bugs), here that's just consulting

Former Member
0 Kudos

Thank you very much, You are the king. Great answer.