$excel->ActiveWorkbook->Close(0); $excel->Quit(); #### $excel = Win32::OLE->GetActiveObject('Excel.Application'); if ($@) { PrintError("Excel not Installed.\n"); return 0; } unless (defined $excel) { $excel = Win32::OLE->new('Excel.Application', 'Quit' ) || (sub { die "Cannot start Excel.\n";return 0 }); } $sheet = $book->Worksheets("Sheet1"); $sheet->Activate(); # some actions... $book->SaveAs($excelfile); $excel->ActiveWorkbook->Close(0); $excel->Quit();