my $commenttxt = $comment1->Text(); #### #!e:/perl/bin/perl.exe use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my($value,$formula); $Win32::OLE::Warn = 3; # die on errors... # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->Workbooks->Open("C:/temp/test/test1.xls"); # select worksheet number 1 (you can also select a worksheet by name) my $Sheet = $Book->Worksheets(1); #test case limit to first few cols and rows foreach my $row (1..4) { foreach my $col (1..3) { # skip empty cells next unless defined $Sheet->Cells($row,$col)->{'Value'}; my $cell1 = $Sheet->Cells($row,$col); my $comment1 = $cell1->Comment(); my $commenttxt = $comment1->Text(); # print out the contents of a cell $value=$Sheet->Cells($row,$col)->{'Value'}; $formula=$Sheet->Cells($row,$col)->{'Formula'}; #print the comments printf("Comment: $commenttxt\n"); if($value eq $formula) { printf("Value:$value\n"); } else { printf("Formula:$formula, value:$value\n"); } } } # clean up after ourselves $Book->Close;