develooper Front page | perl.beginners | Postings from December 2002

win32::ole - Excel - Can't call method "Worksheets"

Paul Kraus
December 23, 2002 11:18
win32::ole - Excel - Can't call method "Worksheets"
Message ID:
When I run the following code I get this error: Can't call method
"Worksheets" on an undefined value.
I added the die statement for the $book declaration and it does die.
Which makes me believe that it cannot find $excelfile.
So I tried coding the full path and I get the same result. armonth.xls
is in the same folder as the script.
What is really bizarre is the script worked Friday when I left. <shrug>.

The file still exists and the spelling is correct.
Any ideas?

 my $excelfile = 'armonth.xls';
    use Win32::OLE qw(in with);
    use Win32::OLE::Const 'Microsoft Excel';
    use Win32::OLE::Variant;
    use Win32::OLE::NLS qw(:LOCALE :DATE);
    my $excel = Win32::OLE->GetActiveObject('Excel.Application')
 	|| Win32::OLE->new('Excel.Appliciation','Quit');
    $book=$excel->workbooks->open($excelfile) or die "dead\n";
    my $sheet;
    $sheet=$book->worksheets('AgeRaw') if ($_[0] eq "Age");
    $sheet=$book->worksheets('ReceiptsRaw') if ($_[0] eq "Cash");

Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About