Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Insert image in Word through ABAP


There is some very nice example on creating Word document through ABAP ( using OLE, but would anybody please give hint on how to insert an image (like company logo) into the Word document.

Would it be something like:

CALL METHOD OF xxxx 'lmage'


#1 = <url>


Thanks a lot !

Patrick Cheung

Former Member
Former Member replied

Hello Patrick,

Try this, though I havn't managed to move the pic to any place other than the current cursor position

  type-pools ole2 .

* word declarations
  data: application      type ole2_object.
  data: word             type ole2_object.
  data: documents        type ole2_object.
  data: newdoc           type ole2_object.
  data: actdoc           type ole2_object.
  data: selection        type ole2_object.
  data: inlineshapes     type ole2_object.

  IF sy-subrc NE 0 .
    MESSAGE s000(su) WITH 'Error while creating OLE object!'.

  GET PROPERTY OF word 'documents' = documents.
  CALL METHOD OF documents 'Add' = newdoc.
*    #1 = 0.

  call method of newdoc 'Activate'.

*--Getting active document handle
  GET PROPERTY OF word 'activedocument' = actdoc .

*--Getting applications handle

  GET PROPERTY OF word 'Selection' = selection.

*--setting object's visibility property
  SET PROPERTY OF word 'visible' = '1' .

  GET PROPERTY OF selection 'InlineShapes' = inlineshapes.

* insert the picture in default (top left) position
  data: h_logo      type ole2_object.
  data: h_ins_logo      type ole2_object.
  data: h_logo_left      type ole2_object.
  data: h_pos_logo      type ole2_object.

  CALL METHOD OF inlineshapes 'AddPicture' = h_ins_logo
    #1 = 'C:\logo_updown.gif'.    " <-- put your pic location here

2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question