# use existing instance if Excel is already running unless (defined $excel) { eval { $excel = Win32::OLE->GetActiveObject('Excel.Application') }; die "Excel not installed" if $@; } unless (defined $excel) { $excel = Win32::OLE->new('Excel.Application', 'Quit') or die "Oops, cannot start Excel"; } #to avoid excessive dialogs when saving in non-Excel format $excel->{DisplayAlerts} = 0;