Hi, monks,
I'm trying to scale the inserted image in an Excel file but in vain. Could someone enlighten me? Thanks in advance!
Following is the code I've tried:

use strict; use warnings; use OLE; use Win32::OLE::Const "Microsoft Excel"; my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $excel->{Visible} = 1; my $workbook = $excel->Workbooks->Open("D:/test.xls"); my $sheet = $workbook->Worksheets("Sheet 1"); my $image = $sheet->Pictures->Insert("D:/test.jpg"); #Inserts image s +ucessfully #The following code fails $image->{ShapeRange}->ScaleWidth("0.06, 0,2"); #Tries to scale with to + 6% but fails $image->{ShapeRange}->ScaleHeight("0.06, 0,2"); #Tries to scale height + to 6% but fails #Saves and quits $workbook->Save; $workbook->Close;

Solution found!

Just fixed the problem on my own:
The problem was with the ScaleWidth paramters AND the select property!
my $shape = $image->{ShapeRange}; $shape->Select; $shape->ScaleWidth(0.06,1); $shape->ScaleHeight(0.06,1);

In reply to How do I scale the inserted image in Excel? by ZJ.Mike.2009

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.