VB如何释放EXCEL
Sub ConExcel() '连接EXCEL表
Set ModPublic.xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ModPublic.xlBook = xlApp.Workbooks.Open(FrmSystemMain.Tdz.Text) '打开EXCEL文件
End Sub
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function WinStationTerminateProcess Lib "winsta.dll" (ByVal hServer As Long, ByVal ProcessID As Long, ByVal ExitCode As Long) As Long
Sub QuitExcel() '关闭并保存EXCEL表
ModPublic.xlBook.Save
xlHwnd = xlApp.hwnd
Dim PID As Long
Call GetWindowThreadProcessId(xlHwnd, PID)
ModPublic.xlBook.Close (True)
Set ModPublic.xlBook = Nothing
ModPublic.xlApp.Quit
Set ModPublic.xlApp = Nothing
End Sub