*-* 请大家看看这两种写法有什么不同,set excel对象为nothing了,在进程中还有EXCEL!
Dim excel_App As Excel.Application
Dim excel_Book As Excel.Workbook
Dim excel_sheet As Excel.Worksheet
Set excel_App = CreateObject("Excel.Application")
Set excel_Book = excel_App.Workbooks.Open("c:\sss.xls")
Set excel_sheet = excel_Book.Worksheets(1)
excel_sheet.Cells(1, 4) = "随便写点什么"
excel_sheet.Range("D2").Select
'如果把上面两句写改成 下面两句,在执行完,Excel进程在进程中不退出(只有关闭整个VB程序,才会退出),不知是为什么?
'Cells(1, 4) = "随便写点什么"
'Range("D2").Select
MsgBox "请查看进程中是否有EXCEL进程!"
excel_App.ActiveWorkbook.Close True 'False '是否对EXCELL进行更改。
excel_App.Quit
Set excel_sheet = Nothing
Set excel_App = Nothing
MsgBox "释放完毕!请查看进程中是否有EXCEL进程!"
'Set excel_sheet = Nothing
'Set excel_Book = Nothing
'excel_App.Quit
'Set excel_App = Nothing