I am trying to do some modification to charts in Excel worksheet using the following Perl code:
$ex = Win32::OLE->new ('Excel.Application')
or confess "could not instantiate Excel.Application: $!\n";
my $workbook = $ex->Workbooks->Open ($file)
or confess "failed to open $file: $!";
my $charts_ws = $workbook->Worksheets ("Charts");
my $charts_col = $charts_ws->ChartObjects;
for (my $i = 0; $i != $charts_col->Count; ++$i)
{
my $chart = $charts_col->Item ($i); # XXX the problem is here
}
$workbook->Close;
Everything seems to work until the XXX marked line. Unfortunately, I get the following error:
Win32::OLE(0.1709) error 0x800a03ec
in METHOD/PROPERTYGET "Item" at test.pl line 557
I was not able to decipher what is the 0x800a03ec HRESULT value about.
(Why do I always find the answer few seconds after I post a question here?)
Solution: I should have used
$charts_ws->ChartObjects ($i)->Chartand I should start the loop from index 1.