Posted: Thu Nov 03, 2011 2:22 pm Post subject: Insert Picture Image in Excel using OLE Automation
*...Declaration for OLE related Objects
DATA : excel TYPE ole2_object,
workbooks TYPE ole2_object,
shapes TYPE ole2_object,
sheet TYPE ole2_object,
excel_filename TYPE draw-filep,
excel_new type rlgrap-fielname,
l_image_path TYPE string.
* -START THE EXCEL APPLICATION
CREATE OBJECT excel 'EXCEL.APPLICATION'.
CALL METHOD OF excel 'WORKBOOKS' = workbooks.
*-Set Visible 0
SET PROPERTY OF excel 'VISIBLE' = 0.
*-Open the excel
CALL METHOD OF workbooks 'OPEN' EXPORTING
#1 = excel_filename.
CALL METHOD OF excel 'Worksheets' = sheet
EXPORTING #1 = 1.
*-Activate the 1st worksheet
CALL METHOD OF sheet 'Activate'.
*-Get refernce to Shapes
GET PROPERTY OF sheet 'Shapes' = shapes.
* This method is suitable for Office 10
IF NOT excel IS INITIAL.
DATA: l_ver TYPE char255.
GET PROPERTY OF excel 'Version' = l_ver.
CALL METHOD cl_gui_cfw=>flush.
IF l_ver GE '14.0'.
CALL METHOD OF shapes 'AddPicture'
#1 = l_image_path "image file name on presentation server
#2 = '1'
#3 = '1'
#4 = 90 "left
#5 = 790 "top
#6 = 190 "right
#7 = 45. "bottom
GET PROPERTY OF excel 'ACTIVESHEET' = sheet.
CALL METHOD OF sheet 'SAVEAS' EXPORTING
#1 = excel_new
#2 = 1.
CALL METHOD OF workbooks 'CLOSE'.
CALL METHOD OF excel 'QUIT'.
FREE OBJECT excel.
FREE OBJECT sheet.
FREE OBJECT workbooks.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.