Kill specific Excel process

1. KillSpecificExcelFileProcess(“example1.xlsx”);

2. private void KillSpecificExcelFileProcess(string excelFileName){

var processes = from p in Process.GetProcessesByName(“EXCEL”)
select p;

foreach (var process in processes){

if (process.MainWindowTitle.Contains(“Microsoft Excel – ” + excelFileName))

process.Kill();

}

}

Excel don’t save on closing

oWB.BeforeSave += new Microsoft.Office.Interop.Excel.WorkbookEvents_BeforeSaveEventHandler(oWB_BeforeSave);

 

void oWB_BeforeSave(bool SaveAsUI, ref bool Cancel){

//SaveAsUI = false;

Cancel = true;

throw new Exception(“The method or operation is not implemented”);

}