OLE: Object Linking and Embedding
Create MS Word document using OLE2 technique. OLE is set of APIs to create and display a compound document.
Sample Code:
*&---------------------------------------------------------------------*
*& Report ZOLE_WORD
*&---------------------------------------------------------------------*
REPORT zole_word.
*===Type Pool Declaration
TYPE-POOLS: ole2.
*===Variable Declaration to hold OLE objects
DATA: v_word TYPE ole2_object,
v_documents TYPE ole2_object,
v_document TYPE ole2_object,
v_selection TYPE ole2_object.
*===Create WORD object
CREATE OBJECT v_word 'WORD.APPLICATION'.
SET PROPERTY OF v_word 'Visible' = '1' .
CALL METHOD OF v_word 'Documents' = v_documents.
CALL METHOD OF v_documents 'Add' = v_document.
CALL METHOD OF v_word 'Selection' = v_selection.
*===Enter Content for Word Document
CALL METHOD OF v_selection 'TypeText'
EXPORTING
#1 = 'Ole Word!'.
*===Create and Save document at specified location
CALL METHOD OF v_document 'SaveAs'
EXPORTING
#1 = 'C:\OLE_WORD.doc'.
On execution, Word Document is created at specified location!
very good^^ thank you.
ReplyDelete