Public Sub CreateNew_Word(ByVal strResult As List(Of String)) 'Added Code 'Description:Get all running winword processes then stored it in the list Dim processIds As New List(Of Integer)() For Each process__1 As Process In Process.GetProcessesByName("winword") processIds.Add(process__1.Id) Next '***WORD FILE GENERATION HERE**** 'Remove clean-up code to test the killing of process 'ReleaseObject(rng) 'newDoc.Close(False) 'ReleaseObject(newDoc) 'WordApp.Application.Quit(False) 'ReleaseObject(WordApp) 'GC.Collect() 'GC.WaitForPendingFinalizers() 'GC.Collect() 'GC.WaitForPendingFinalizers() 'Description: As the existing processes has been stored in the list. Those processes will not be killed. Only the generated winword.exe will be killed because it is not inside the list. For Each process__1 As Process In Process.GetProcessesByName("winword") If Not process__1.HasExited AndAlso Not processIds.Contains(process__1.Id) Then process__1.Kill() End If Next
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)