Skip to Content
author's profile photo
Former Member

Populating WORD with internal table from ABAP program

Hello all

I would like to be able to open a new word document from within an ABAP program and then populate the document with data from an internal table.

I can open the document but when it comes to putting text on the new document I am at a loss.

Can anyone help?

I have recorded a macro within WORD but don't know how to structure the commands to put the text into the document!

**************ABAP CODE**********************

DATA: word_doc TYPE ole2_object,

x TYPE ole2_object,

doc TYPE ole2_object.

start-of-selection.

CREATE OBJECT word_doc 'WORD.APPLICATION'.

CALL METHOD OF word_doc 'Documents' = x.

CALL METHOD OF x 'Add' = doc.

SET PROPERTY OF word_doc 'Visible' = 1.

CALL METHOD OF word_doc 'AppShow'.

****CODE FROM MACRO*********************

Documents.Add DocumentType:=wdNewBlankDocument

Selection.TypeText Text:="Hello"

Selection.TypeParagraph

Selection.TypeText Text:="World"

Selection.TypeParagraph

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Aug 06, 2004 at 01:53 PM

    Check out the sample program SAPRDEMOOFFICEINTEGRATION in at least 46C. This example shows you how to use SAP office integration. In my opinion this is a heck of lot easier than using direct OLE. You will also find several threads in this forum on Office Integration.

    Add comment
    10|10000 characters needed characters exceeded