Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting an image in a specific cell

Status
Not open for further replies.

padawanlinuxero

Programmer
Oct 4, 2007
1
MX
Good day
I have a problem I need to put an image on a excel file using Perl, so far I have done this :
Code:
$Hoja -> Range("E47")->Select();
$excel->ActiveSheet->Pictures->Insert("c:\\projectword\\$filename2.jpg");

but so some reason in the excel file it ends up in the upper part of the file and not in the cell i selected why??

Am I doing something wrong?


 
Hi there,

Try this from
perlmonks said:
To see how it's done in an xls, fire up the macro recorder in Excel then insert your image. Now move the image. Stop the macro recorder and open up Excel's VBA IDE. Take the generated code and convert it to perl.
Code:
use strict;
use warnings;
use Win32::OLE;

my $excel = Win32::OLE->CreateObject('Excel.Application');
$excel->{Visible} = 1;

my $wb = $excel->Workbooks->Add;
$wb->ActiveSheet->Pictures->Insert( "C:\\s\\x.png" )->Select;
$excel->Selection->ShapeRange->IncrementLeft( 40 );
$excel->Selection->ShapeRange->IncrementTop( 40 );

__END__
Sub Macro1()
' Macro recorded with Macro Recorder
' Tools -> Macro -> Record new macro
    ActiveSheet.Pictures.Insert( _
        "C:\s\x.png").Select
    Selection.ShapeRange.IncrementLeft 40
    Selection.ShapeRange.IncrementTop 40
End Sub

Mike

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top