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: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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |