Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

How do I scale the inserted image in Excel?

by ZJ.Mike.2009 (Scribe)
on Nov 19, 2014 at 09:11 UTC ( [id://1107718]=perlquestion: print w/replies, xml ) Need Help??

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

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);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-16 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found