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: 

ole - writing to word document

Former Member
0 Kudos
247

Hi,

I have created a new word document with a table of 1 row and 3 columns using the ole concept. The text in all the 3 columns should be of different font and size. Please let me know if this can be done ?

Attached below is the code which i have used. But with this everything is getting printed with same font and size. Please let me know if there is anything wrong in it?

get property of gs_word 'documents' = gs_documents.

call method of gs_documents 'add'.

get property of gs_word 'activedocument' = gs_actdoc.

get property of gs_actdoc 'application' = gs_application.

get property of gs_application 'options' = gs_options.

set property of gs_options 'measurementunit' = '1'. "cm

get property of gs_application 'selection' = gs_selection.

get property of gs_selection 'font' = gs_font.

get property of gs_selection 'paragraphformat' = gs_parformat.

perform font_style using 'arial' '12' '1' '0' '0' '1'.

call method of gs_selection 'typeparagraph'.

perform create_table using '1' '3'.

perform fill_cell using '1' '2' 'abc'.

perform font_style using 'arial' '10' '0' '0' '0' '1'.

perform fill_cell using '1' '3' 'di-03

version 2.00'.

form font_style using value(p_0383)

value(p_0384)

value(p_0385)

value(p_0386)

value(p_0387)

value(p_0388).

set property of gs_font 'name' = p_0383.

set property of gs_font 'size' = p_0384.

set property of gs_font 'bold' = p_0385.

set property of gs_font 'italic' = p_0386.

set property of gs_font 'underline' = p_0387 .

set property of gs_parformat 'alignment' = p_0388.

endform.

form create_table using value(p_0262)

value(p_0263).

get property of gs_actdoc 'tables' = gs_tables.

get property of gs_selection 'range' = gs_range.

call method of gs_tables 'add' = gs_table

exporting

#1 = gs_range "handle for range entity

#2 = p_0262 "number of rows

#3 = p_0263. "number of columns

*

get property of gs_table 'borders' = gs_table_border.

set property of gs_table_border 'enable' = '1'. "with border

endform. " create_table

form fill_cell using value(p_0185)

value(p_0186)

value(p_0187).

call method of gs_table 'cell' = gs_cell

exporting

#1 = p_0185

#2 = p_0186.

get property of gs_cell 'range' = gs_range.

set property of gs_range 'text' = p_0187.

endform.

Thanks

Aruna

4 REPLIES 4

venkata_ramisetti
Active Contributor
0 Kudos
81

HI,

Check the standard include program LRHVSF08.

Check also standard demo program SAPRDEMOWORD97INTEGRATION.

Thanks,

Ramakrishna

Message was edited by: Ramakrishna Prasad

former_member188685
Active Contributor
0 Kudos
81

Hi Aruna,

check this example ,it may help you..

http://www.sap-img.com/abap/xml-file-to-word-document-through-sap.htm

Thanks

vijay

Former Member
0 Kudos
81

Hi Aruna,

Check this link.

An easy reference for ole automation.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2...

This may help you.

Thanks,

Bhaskar

Former Member
0 Kudos
81

Hi Aruna,

Try FM

LXE_SP_ITF_TO_MSWORD

Just go through the code of this FM... I think it will help you in understanding how to pass the fonts and size to the internal table.

OR FMs of the Func. Grp. DSVAS_MSWORD

Hope it helps...

Lokesh

Pls. reward appropriate points