perl win32 OLE arcana: 1

An obscure problem encountered while trying to set the cell background color in Excel:

$sheet->Range("q2q6")->Interior->{ColorIndex} =8;

returns the following message: OLE (0.1709) ERROR 0X800a03ec METHOD/PROPERTYGET “Range” at blahblah

A search turned up several long discussions that were ultimately totally irrelevant. The problem is that you can’t set color using this kind of range with this method; if you use this method, you have to do it a cell at a time:

foreach my $y (2..6) {
my $range = 'q' . $y;
$sheet->Range($range)->Interior->{ColorIndex} =8;
}

This entry was posted in Programming. Bookmark the permalink.