End Function
‘關(guān)閉Excel應(yīng)用
Function CloseExcelApp(xlApp As Object)
On Error Resume Next
xlApp.Quit
Set xlApp = Nothing
End Function
’建立Excel應(yīng)用
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
‘檢測(cè)EXCEL環(huán)境
Function CheckExcel() As Boolean
Dim xlCheckApp As Object
Set xlCheckApp = CreateObject(“Excel.Application”)
If xlCheckApp Is Nothing Then
MsgBox “對(duì)不起,系統(tǒng)未檢測(cè)到EXCEL安裝,請(qǐng)重新檢查EXCEL是否被正確安裝!”
CheckExcel = False
xlCheckApp.Quit
Set xlCheckApp = Nothing
Exit Function
Else

