Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Embedding Image in Excell

by merrymonk (Hermit)
on Feb 16, 2011 at 09:11 UTC ( [id://888472]=perlquestion: print w/replies, xml ) Need Help??

merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

I am using Excel 2007 and 2010 on PCs using Windows XP.
I use the following Perl to insert Pictures into a spreadsheet.
$image_file_full = <full path to image> # get a cell in which the image is to be stored $cell_tg = $sheet->Range($range); # insert the image $pic_cur = $sheet->Pictures->Insert($image_file_full); # position the image in the top left hand corner of the cell $pic_cur ->{Top} = $cell_tg->Top; $pic_cur ->{Left} = $cell_tg->Left;

This works fine except that if the spreadsheet is sent to another computer the picture is no longer there and I get an error message saying
“The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location”.
Is there any way the image can be ‘embedded’ in the spreadsheet so that the ‘disappearing’ problem is not found when the spreadsheet is moved from one pc to another?
I know I could send the image as well but I would prefer not to do that since the link would have to be remade.

Replies are listed 'Best First'.
Re: Embedding Image in Excell
by Corion (Patriarch) on Feb 16, 2011 at 10:12 UTC
      I recorded an Excel macro to embed an image and got the following
      ActiveSheet.OLEObjects.Add(Filename:="C:\aaaaa\700 plate selection.jpg +", _ Link:=False, DisplayAsIcon:=False).Select
      However, I found a difference when I ran this macro on 2 PCs.
      On the 1st PC all was well and I could see the image.
      On the 2nd PC all I got was a rectangle with the name of the image in the rectangle.
      I could see the image when I double clicked on the rectangle.
      I am not aware of any settings for Excel that gives this difference.
      What do I do to ensure that I always see the image as I found on the 1st PC
      P.S. I have not yet started to convert the macro to Perl.
      If anyone has the time to help I would appreciate it as I suspect I am going to have problems!
Re: Embedding Image in Excell
by Anonymous Monk on Feb 16, 2011 at 10:09 UTC
    Is there any way the image can be ‘embedded’ in the spreadsheet so that the ‘disappearing’ problem is not found when the spreadsheet is moved from one pc to another?

    Probably, but its unlikely the answer would be found on a perl forum excel ole embed image

Re: Embedding Image in Excell
by cjb (Friar) on Feb 16, 2011 at 10:10 UTC
Re: Embedding Image in Excell
by Anonymous Monk on Oct 05, 2011 at 19:01 UTC
    I have been researching the same problem, so if it means anything now… In Excel 2010, .Pictures.Insert() will insert linked image. Pre-2010 versions would embed picture in the document with this command. It seems that one must use Sheet.Shapes.AddPicture() method to embed an image in Excel 2010.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://888472]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found