返回對象時,對象變量或與塊變量未設置錯誤我想使用應返回Excel.Application
對象的函數:的Excel VBA:從功能
Dim ExcelApp As Object
Set ExcelApp = getExcelApp()
Function getExcelApp() As Object
Dim ExcelApp As Object
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = False
ExcelApp.ScreenUpdating = False
ExcelApp.DisplayAlerts = False
ExcelApp.EnableEvents = False
getExcelApp = ExcelApp
End Function
但我得到一個object variable or with block variable not set
錯誤。什麼是錯的,如何完成我想要的?