Kill Excel Process Programmatically

 
Kill all excels in process..VB.net
  1. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As IntegerByRef lpdwProcessId As IntPtr) As IntPtr  
  2. Dim xlapp As New excel.Application  
  3.     .  
  4.     .  
  5. Dim processId1 As IntPtr  
  6. GetWindowThreadProcessId(xlapp.Hwnd, processId1)  
  7. Dim excelProcess1 As Process = Process.GetProcessById(processId1.ToInt32())  
  8. Debug.WriteLine(processId1)  
  9. excelProcess1.Kill()  
  10. xlapp = Nothing  
  11. GC.Collect()  
  12. GC.WaitForPendingFinalizers()