【www.tuzhexing.com--教育考试】
End Function
‘关闭Excel应用
Function CloseExcelApp(xlApp As Object)
On Error Resume Next
xlApp.Quit
Set xlApp = Nothing
End Function
’建立Excel应用
Function CreateExcelApp(QuitApp As Boolean) As Object
On Error Resume Next
Dim xlObject As Object
If CheckExcel Then
Set xlObject = GetObject(, “Excel.Application”)
If err.Number 《》 0 Then
Set xlObject = Nothing
Set xlObject = CreateObject(“Excel.Application”)
CreateExcelApp = xlObject
Else
If QuitApp Then
xlObject.Quit
Set xlObject = Nothing
Set xlObject = CreateObject(“Excel.Application”)
End If
CreateExcelApp = xlObject
End If
End If
End Function
‘检测EXCEL环境
Function CheckExcel() As Boolean
Dim xlCheckApp As Object
Set xlCheckApp = CreateObject(“Excel.Application”)
If xlCheckApp Is Nothing Then
MsgBox “对不起,系统未检测到EXCEL安装,请重新检查EXCEL是否被正确安装!”
CheckExcel = False
xlCheckApp.Quit
Set xlCheckApp = Nothing
Exit Function
Else