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: 

Insert picture in word using OLE

Former Member
0 Kudos

Hi All,

My requirement is:-- using Abap code and OLE technology

1) Read existing word document

2) Read .bmp file

3) insert .bmp file in word document

4) save word document

5) Quit

I have written below code, but it is not working.. Pls guide.

INCLUDE OLE2INCL.

Data: word type ole2_object,

docs type ole2_object,

doc type ole2_object,

selection type ole2_object,

o_bmpshapes type ole2_object,

o_logo type ole2_object,

gs_picture(128).

START-OF-SELECTION .

gs_picture = 'd:\BMP\music.BMP'.

CREATE OBJECT word 'WORD.APPLICATION'.

*To make word visible

SET PROPERTY OF word 'Visible' = '1'.

*Opening a new word document

GET PROPERTY OF word 'Documents' = docs.

*--Getting active document handle

GET PROPERTY OF WORD 'ActiveDocument' = doc .

CALL METHOD OF docs 'FileOpen'

EXPORTING #1 = 'D:\TEMP\tes1.doc'.

GET PROPERTY OF doc 'InlineShapes' = o_bmpshapes.

call method of o_bmpshapes 'InsertPicture' = o_logo

exporting

#1 = gs_picture

#2 = '2'.

call method of doc 'SaveAs'

exporting

#1 = 'D:\TEMP\tes2.doc'

#2 = 'wdFormatDocument'.

call method of word 'Quit' .

end-of-selection.

free: word, doc, docs.

Rishi

1 REPLY 1

Former Member
0 Kudos

check this thread :

Mathews