report abap word
TRANSCRIPT
-
8/18/2019 Report Abap Word
1/1
REPORT zword.INCLUDE ole2incl.
DATA: gs_word TYPE ole2_object,gs_documents TYPE ole2_object,gs_document TYPE ole2_object,gs_selection TYPE ole2_object.
START-OF-SELECTION.
CREATE OBJECT gs_word 'WORD.APPLICATION'. SET PROPERTY OF gs_word 'VISIBLE' = '1'.
CALL METHOD OF gs_word 'Documents' = gs_documents. CALL METHOD OF gs_documents 'Add' = gs_document. CALL METHOD OF gs_document 'Activate'.
** Gets the cursor position GET PROPERTY OF gs_word 'SELECTION' = gs_selection.
** To display text in 1st page CALL METHOD OF gs_selection 'TYPETEXT' EXPORTING #1 = 'This is the Page One text!'
#2 = 'Esta es la segunda linea'.** Inserts a page break CALL METHOD OF gs_selection 'INSERTBREAK'.
** To display text in 2nd page CALL METHOD OF gs_selection 'TYPETEXT' EXPORTING #1 = 'This is the Page Two text!'.
** Save Word document*Please change the path of the file appropriately CALL METHOD OF gs_document 'SaveAs'
EXPORTING #1 = 'C:\Documents and Settings\nisha_vengal\Desktop\Test.doc'.
CALL METHOD OF gs_word 'Quit'.
FREE OBJECT gs_word.