#!usr/bin/perl -w use strict; use Win32::OLE qw( HRESULT ); use constant False => 0; use constant True => 1; my $Excel; { # Open Excel $Excel = Win32::OLE->new( 'Excel.Application', sub { $_[0]->Quit; } ) || die( '[FATAL]: could not open Excel', $! ); $Excel->{Visible} = False; } { my $Book = $Excel->Workbooks->Add; # Add workbook my $Sheet = $Book->Worksheets->Add; # Add worksheet to work book $Excel->{DisplayAlerts} = False; # Don't display alerts $Sheet->Delete(); # Delete sheet $Book->Close( { SaveChanges => False } ); # Close the work book # Excel exits via the deconstructor closure sub { $_[0]->Quit }; listed in the open method } #### if( Win32::Ole->LastError == HRESULT(0x800a01a8)){ print "Error\n"; }