#!/usr/local/bin/perl - use warnings; use diagnostics; use strict; use Win32::OLE::Const 'Microsoft Excel'; # use Win32::OLE::Variant; $Win32::OLE::Warn = 3; my $i = 0; # Excel application object reference. my $oExcel; # Workbook object reference. my $oWkBk; # Sheet object reference. my $oWkSht; $oExcel = (Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit')); $oExcel->{Visible} = 1; $oWkBk = $oExcel->Workbooks->Add(); $oWkSht = $oWkBk->Worksheets('Sheet1'); $oWkSht->Activate(); $oWkSht->Range('D12')->{Value} = 1; $oWkSht->Range('D13')->{Value} = '#N/A'; my $arTestNA = $oWkSht->Range('D12:D13')->{Value}; $i = 0; print("\n\t\t\$arTestNA->[$i][0] = ".$arTestNA->[$i][0]."\n\n"); $i = 1; print("\n\t\t\$arTestNA->[$i][0] = ".$arTestNA->[$i][0]."\n\n"); $oExcel->{DisplayAlerts} = 0; $oWkBk->Close({SaveChanges=>'false'}); $oExcel->{DisplayAlerts} = 1; undef $oWkBk; $oExcel->{WindowState} = xlMinimized; __END__