SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Insert Picture Image in Excel using OLE Automation



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Thu Nov 03, 2011 2:22 pm    Post subject: Insert Picture Image in Excel using OLE Automation Reply with quote

Code:
Sample Code:
*...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.
                 ENDIF.

               IF l_ver GE '14.0'.
    CALL METHOD OF shapes 'AddPicture'
     EXPORTING
     #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
                 ENDIF.
   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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.