Quit()
Excel.Application
Application.Quit
Nothing
null
Dim excelProcesses() As Process = Process.GetProcessesByName("Excel") For Each p As Process In excelProcesses If p.MainWindowTitle.Length = 0 Then p.Kill() End If Next
''-- Kill Stray EXCEL.EXE Process ----------------------------------------------------- ' This uniquely identifies this instance of Excel so we can kill the process later guid = System.Guid.NewGuid().ToString().ToUpper() app.Visible = True ' Excel MUST be visible in order for this technique to work! app.Caption = guid ' Don't bother trying the Quit method, since it typically fails when called from .NET 'app.Quit() 'System.Runtime.InteropServices.Marshal.ReleaseComObject(app) 'app = Nothing Dim excelProcesses() As Process = Process.GetProcessesByName("Excel") For Each p As Process In excelProcesses If p.MainWindowTitle.Contains(guid) Then p.Kill() End If Next
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.