G
Guest
When opening Excel with the following code snippet (located in an Access module) and dropping the XIRR function (an Excel add-in in the Analysis Tool pak) into a cell; the cell shows "#NAME?". The current version of Excel does not recognize this add-in function. But, if I open Excel and then run the code the function works! Do I need to explicitly reference Excel's ad-in when opening Excel in automation? Thanks for thoughts or solutions.
Forrest
'Open or create an instance of Excel and add a workbook
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application") 'Activate current Excel object
If Err.Number <> 0 Then
Err.Clear ' Clear Err object in case error occurred.
Set xlApp = CreateObject("Excel.Application") 'Create an instance of Excel
End If
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
Forrest
'Open or create an instance of Excel and add a workbook
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application") 'Activate current Excel object
If Err.Number <> 0 Then
Err.Clear ' Clear Err object in case error occurred.
Set xlApp = CreateObject("Excel.Application") 'Create an instance of Excel
End If
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")