I want to use a function that should return an Excel.Application Object:
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
But I get a object variable or with block variable not set error. What is wrong and how to accomplish what I want?