use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE; use Win32::OLE::Const; $Win32::OLE::Warn = 3; # die on errors... $file = "C:\\testw.txt"; open (TTT, ">$file") || die "error"; print TTT "test"; $filename = "C:\\book1.xls"; $filter = 'PNG'; # can be GIF, JPG, JPEG or PNG $pngnm = "C:\\test"; eval{ my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # use the Excel application if it's open, otherwise open new my $Book = $Excel->Workbooks->Open( $filename ); # open the file foreach my $Sheet (in $Book->Sheets) { # loop through all sheets foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet #$datewk = join("".split(/\s+/, $Date)); $savename = "$pngnm" . ".$filter"; #$savename = "$dirpath\\$pngnm" . ".$filter"; # Write image to PNG file $ChartObj->Chart->Export({ FileName => $savename, FilterName => $filter, Interactive => 0 }); } } $Book->Close({SaveChanges=>0}); }; $err = $@; print TTT $err;