Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm sure the following line is wrong, but i don't know how to change it.
I get the message: cannot call method "Text". Where can I get a list of methods?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;
edited: Thu Oct 23 19:17:24 2003 by jeffa - code tags (1st line only), switch <a> tag to in-house id tag
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE Excel Extracting Comments
by Nkuvu (Priest) on Oct 23, 2003 at 18:42 UTC | |
|
Re: Win32::OLE Excel Extracting Comments
by Nkuvu (Priest) on Oct 23, 2003 at 22:39 UTC | |
|
Re: Win32::OLE Excel Extracting Comments
by Grygonos (Chaplain) on Oct 23, 2003 at 20:25 UTC | |
by Nkuvu (Priest) on Oct 23, 2003 at 20:45 UTC |