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

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

From:
Paul Kraus
Date:
December 23, 2002 11:18
Subject:
win32::ole - Excel - Can't call method "Worksheets"
Message ID:
000801c2aab8$05932930$64fea8c0@pkrausxp
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?

Code
-----
 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);
    $win32::OLE::Warn=3;
    my $excel = Win32::OLE->GetActiveObject('Excel.Application')
 	|| Win32::OLE->new('Excel.Appliciation','Quit');
    $excel->{DisplayAlerts}=0;
    $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
www.pelsupply.com




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About