my $Excel = Win32::OLE->GetActiveObject('Excel.Application'); if ( ! $Excel ) { Win32::OLE->new('Excel.Application', 'Quit'); die 'Could not start Excel'; }