Office 组件都有一个 Quit 方法,直接调用 Quit 方法可以彻底退出该程序
以下以Excel为例子:
Function Automation_To_Excel()
Dim objExcel As Object
' Create a new instance of Excel.
Set objExcel = CreateObject("Excel.Application")
' Show the instance of Excel on the screen.
objExcel.Visible = True
' Open a file named SampleFile.xls
objExcel.Workbooks.Open ("C:\My Documents\SampleFile.xls")
' Explicitly close the instance of Excel to free up memory
' and set the variable to Nothing to free up the name
' space in access.
objExcel.Quit
Set objExcel = Nothing
End Function