Code
# 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($file);
# select worksheet number. Default is 1 (you can also select a worksheet by name)
print "worksheet $worksheet\n";
my $Sheet = $Book->Worksheets($worksheet);
where $worksheet
is an integer obtained as a value from a hash.
Error -
Win32::OLE(0.1709) error 0x8002000b: "Invalid index"
in METHOD/PROPERTYGET "Worksheets" at win32excel.pl
Any suggestions what I might be doing wrong?