Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Insert picture in Excel using OLE

Former Member
0 Likes
3,838

Hi,

Anyone who knows how to insert a picture into an <b>excel</b>-sheet via <b>OLE</b>-technique? I managed to get a lot onto my sheet (borders, colors, etc.) but i haven't found how to insert a picture. Thanks a lot in advance!!

Here's the beginning of my code:

CREATE OBJECT application 'excel.application'.

SET PROPERTY OF application 'visible' = 0.

  • Create workbook

GET PROPERTY OF application 'Workbooks' = workbooks .

CALL METHOD OF workbooks 'Open' = workbook

EXPORTING

#1 = '
***.

  • Create first Excel Sheet

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING

#1 = 1.

CALL METHOD OF sheet 'Activate'.

SET PROPERTY OF sheet 'Name' = 'Bestelling'.

CALL METHOD OF application 'Cells' = cells

EXPORTING

#1 = i

#2 = j.

SET PROPERTY OF cells 'Value' = val .

GET PROPERTY OF cells 'Font' = h_f.

SET PROPERTY OF h_f 'Bold' = bold .

SET PROPERTY OF h_f 'Italic' = italic.

GET PROPERTY OF cells 'Interior' = interior .

SET PROPERTY OF interior 'ColorIndex' = color .

<b></b>

13 REPLIES 13
Read only

Former Member
0 Likes
2,123

anyone?

Read only

0 Likes
2,123

Insert a picture from where?

Regards,

Rich Heilman

Read only

0 Likes
2,123

Insert a picture from a server or c:\-drive,...anywhere. My problem is that i can't insert a picture into Excel via OLE... any solutions?

Read only

Former Member
0 Likes
2,123

Hi,

For the activated sheet, create a property on the following and pass the file path/file name to it.

"Pictures.Insert"

Thanks,

Read only

Former Member
0 Likes
2,123

Hi Siegfried,

You can use <b>Shape</b> object which is the child of <b>range</b> object. Shape object is a member of <b>shapes</b> collection. Please have a look of <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl11/html/xltocOMMap_HV01049651.">Excel Object model</a> for further detail.

Read only

0 Likes
2,123

Thanks for the replies.

I still haven't managed to solve my problem.

@ Sharad: have you already succesfully inserted a picture in Excel via the 'Shape object'? I have tried it but never came to a good result!!

Maybe someone with some sample code?

Read only

0 Likes
2,123

Hi,

I solved the problem my own; in fact it was quite simple:

for the interested ones (in my case not using 'Shape Object'):

GET PROPERTY OF gs_sheet 'Pictures' = gs_picture.

CALL METHOD OF gs_picture 'Insert'

EXPORTING

#1 = 'C:\TEMP\Picture.bmp'.

To state the place where the picture has to be inserted just do a select before the insert of the picture.

CALL METHOD OF gs_application 'Range' = gs_cells

EXPORTING

#1 = 'A1'

#2 = 'A2'.

CALL METHOD OF gs_cells 'Select' = select.

Read only

0 Likes
2,123

Hi Siegfried,

Can you please help me out with the same code, if you can?

My requirement is to insert an image into the excel using OLE.

I tried using the code you presented with.But its not working.

Request inputs of anyone who were able to solve this

Thanks in adv,

Gary

Read only

0 Likes
2,123

i want to insert pictures in samrt form

dynayamically way u inserted in excel

Read only

0 Likes
2,123

But it seems in smartform you could not insert pictures into table lines. And of course you could not transfer smartform table to excel file.....That is unacceptable for the custmor.

Read only

0 Likes
2,123

After 27 months?Continue with your thread.

Read only

0 Likes
2,123

Sorry...mistake reply...I am not a graverobber...

Read only

0 Likes
2,123

Hi Experts,

My requirement si that I need to insert Picture at Bookmark Location in word document.

Bookmark has already been defined in word document which I am opening. Name of bookmark is suppose Sig

The Visual Basic syntax is :

Range = 'doc.Bookmarks("Sig").Range and

In Abap I can write as

GET PROPERTY OF WORD 'ActiveDocument' = doc .

GET PROPERTY OF doc 'Bookmarks' = item.

Now how to proceed. Any ideay ?

Rishi