I have to 2 process excel. For example:
1) example1.xlsx
2) example2.xlsx
How to kill first “example1.xlsx”?
I use this code:
foreach (Process clsProcess in Process.GetProcesses())
if (clsProcess.ProcessName.Equals("EXCEL")) //Process Excel?
clsProcess.Kill();
That kill a both.
I wanna kill just one…
Thank you.
The ProcessMainWindow Title will do it for you, it appends “Microsoft Excel – ” to the name of the file:
So essentially (quick code):
Use:
Edit: Tested and verified to work.