03-15-2009 6:21 AM
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
03-15-2009 1:45 PM