Posted on 2006-04-06
I have an application that uses Excel to create reports in spreadsheets.
Everything works perfectly except at the end when I try to exit Excel using:
if there is a network error and the file could not be automatically saved, the line above is not run...
At the start of the application, I want to close any existing Excel sessions, so I made:
Public Function KillExcel()
Dim EmptyProcess() As Process = Process.GetProcessesByName("EXCEL.EXE")
Dim DeadApp As Process
For Each Victim In EmptyProcess
but for some reason, it will not kill Excel processes, I have used this exact same code to terminate several other processes from other applications, so I know it works.
Is there any reason it is not working? Is there a better way to kill all open Excel processes before running my application?