10-17-2008 1:18 PM
Hi All,
I have a requirement to print the report in a power point template and mail to the users ...
So I found like this is possible with the OLE application 'Powerpoint.Application' but I am not able to find any examples for this , Can some one PL. send me a small Example of this so that I can elaborate on that ......
And Let me know if any other way is possible in SAP for this .....
Thank you,
Girish.
02-12-2009 12:11 PM
Hello,
Try this.. here I'm currently opening a powerpoint file which could contain the template you require
*&---------------------------------------------------------------------*
*& Report ZKRIS_OLE_OPEN_ppt_ADD_DATA
*&
*&---------------------------------------------------------------------*
*& Author : Kris Donald
*& Date : 10-02-2009
*& Purpose : Find some text in ppt and replace it
*&---------------------------------------------------------------------*
*& Date Changed by Tag Description
*&
*&---------------------------------------------------------------------*
REPORT ZKRIS_OLE_OPEN_ppt_ADD_DATA.
selection-screen begin of block b1 with frame title ft1.
parameters p_story(256) default 'C:\test.ppt' lower case.
selection-screen end of block b1.
initialization.
ft1 = 'Template file'.
start-of-selection.
type-pools ole2 .
* ppt declarations
data: application type ole2_object.
data: ppt type ole2_object.
data: presentations type ole2_object.
data: newdoc type ole2_object.
data: actwin type ole2_object.
data: actpres type ole2_object.
data: selection type ole2_object.
data: sliderange type ole2_object.
data: shapes type ole2_object.
data: textbox type ole2_object.
data: textrange1 type ole2_object.
data: textframe type ole2_object.
data: shaperange1 type ole2_object.
data: shaperange2 type ole2_object.
data: shaperange3 type ole2_object.
data: view type ole2_object.
data: font type ole2_object.
data: paraformat type ole2_object.
data: color type ole2_object.
data: slides type ole2_object.
data: slideindex type i.
data: slidecount type i.
slidecount = 1.
data: begin of wa_data,
line(256),
end of wa_data,
it_data like table of wa_data.
*--create the ppt application
CREATE OBJECT ppt 'POWERPOINT.APPLICATION' .
IF sy-subrc NE 0 .
MESSAGE s000(su) WITH 'Error while creating OLE object!'.
LEAVE PROGRAM .
ENDIF .
*--setting object's visibility property
SET PROPERTY OF ppt 'visible' = '1' .
*--open the specified file from presentation server
GET PROPERTY OF ppt 'presentations' = presentations.
CALL METHOD OF presentations 'Open'
EXPORTING
#1 = p_story.
*--Getting active window handle
GET PROPERTY OF ppt 'ActiveWindow' = actwin .
*--Getting active presentation handle
GET PROPERTY OF ppt 'ActivePresentation' = actpres .
* add some text
wa_data = 'This is some text'.
append wa_data to it_data.
data: lv_subrc like sy-subrc.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT
IMPORTING
DATA = it_data[]
CHANGING
RC = lv_subrc
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
get property of actwin 'View' = view.
CALL METHOD OF view 'Paste'.
GET PROPERTY OF actwin 'Selection' = selection.
GET PROPERTY OF selection 'ShapeRange' = shaperange1.
* move text
CALL METHOD OF SHAPERANGE1 'IncrementLeft'
EXPORTING
#1 = '-200'.
CALL METHOD OF SHAPERANGE1 'IncrementTop'
EXPORTING
#1 = '-150'.
* change font
GET PROPERTY OF actwin 'Selection' = selection.
GET PROPERTY OF shaperange1 'TextFrame' = textframe.
GET PROPERTY OF textframe 'TextRange' = textrange1.
GET PROPERTY OF textrange1 'Font' = font.
set property of font 'Size' = '36'.
set property of font 'Name' = 'Arial'.
* change font color
get property of font 'Color' = color.
set property of color 'SchemeColor' = 6.
* center align the object
GET PROPERTY OF textrange1 'ParagraphFormat' = paraformat.
set property of paraformat 'Alignment' = 2.
* add a slide
GET PROPERTY OF actpres 'Slides' = slides.
slidecount = slidecount + 1.
CALL METHOD OF slides 'Add'
EXPORTING
#1 = slidecount
#2 = 12.
* go to the added slide
get property of actwin 'View' = view.
call method of view 'GotoSlide'
exporting
#1 = slidecount.
03-30-2014 7:02 AM
03-30-2014 7:01 AM