Updated
##################################################### ########### open the excel file for parsing ##################################################### my $srcExcelName = "test.xlsx"; my $excelObject=Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $excelObject->{DisplayAlerts} = 0; my $xlsBook=$excelObject->WorkBooks->Open($srcExcelName); my $xlsSheet = $xlsBook->Worksheets("Sheet1"); ########### open the excel file for parsing ##################################################### ########### open the word file for saving ##################################################### my $wordBasicName=$excelFileName; $wordBasicName =~s/\.xlsx?$//; my $saveWordName=$wordBasicName.".docx"; my $wordObject = CreateObject Win32::OLE 'Word.Application' or die $!; $wordObject->{'Visible'} = 0; my $document = $wordObject->Documents->Add; my $selection = $wordObject->Selection; ########### open the word file for saving ##################################################### ########### get the picture in sheets and save them in workdir ##################################################### my $iCount=0; my $picFileType="BMP"; my @picFileArray; foreach my $picObj ( in $xlsSheet->Pictures){ my $savePicName = $workdir."aa".$iCount++.".".$picFileType; $picObj->Copy(); my $clip=Win32::Clipboard(); if( $clip->IsBitmap()){ open CLIPPIC, ">$savePicName"; binmode CLIPPIC; print CLIPPIC $clip->GetBitmap; close CLIPPIC; } push @picFileArray, $savePicName; } foreach ( @picFileArray ){ $selection -> TypeParagraph; $selection -> InlineShapes->AddPicture({ FileName => $_ }); $selection -> TypeParagraph; }
In reply to How to get picture in MS excel and insert them into MS word file by the module win32::OLE? by gongcw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |