Yes. I would say so.

Look for the answer in Using Win32::OLE and Excel - Tips and Tricks. You are looking for:

#$Excel->ActiveSheet­->Pictures->Insert(<­PATH TO THE PIC>);

I don't know why it is commented out

I would read that whole node as it seems to be a juicy source of information about perl, Win32::OLE and Excel.

Also, when wanting to work out how to automate Office apps with perl, it is often helpful to use the macro recorder functions in the Office application then open the macro with Visual Basic Editor (Menus ->Tools -> Macro -> Visual Basic Editor) This will give you a rough idea of what objects and methods are used to perform the desired function. You can then easily translate the macro to Perl.

In this instance the macro recorder created the following in VBA:

ActiveSheet.Pictures.Insert( _ "C:\Documents and Settings\tech\My Documents\My Pictures\Sampl +e.jpg").Select
Here is my tested code:
#!c:/perl/bin/perl -w use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; my $excelfile = 'c:/ben.xls'; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); my $Book = $Excel->Workbooks->Add(); $Book->SaveAs($excelfile); #Good habit when working with OLE, save +often. my $Sheet = $Book->Worksheets("Sheet1"); $Sheet->Activate(); $Sheet->{Name} = "DidItInPerl"; $Sheet->Pictures->Insert('C:\Documents and Settings\tech\My Documents\ +My Pictures\Sample.jpg');

In reply to Re: Win::OLE Add image by blm
in thread Win::OLE Add image by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.