It's giving me that error because the formula does not exist in excel when I
open excel from access. It's easy to proove. When I open excel normally, I
can go to Insert>Function, and there is networkdays. When I open an excel
spreadsheet (even through the method you gave), i go to Insert>Function and
networkdays is not there, nor are any formulas added through the extra
add-ins.
What version of excel do you have? I am using 2000.
> The code looks for a Date in Cells A1 and B1 on Sheet2, is it possible you
> did not enter dates in those cells? That is the only way I could get it to
[quoted text clipped - 59 lines]
> > > > > >
> > > > > > Is there any way around this?
Ralph - 29 Sep 2006 20:46 GMT
Excel 2003
The following will load the addin too.
Dim xlApp As New Excel.Application
Dim xlWb As Excel.Workbook
Dim xlWbA As Excel.Workbook
Dim xlA As Excel.AddIn
Dim xlSheet As Excel.Worksheet
Dim strPath As String
strPath = CurrentProject.Path & "\"
Set xlWb = xlApp.Workbooks.Open(strPath & "New Microsoft Excel
Worksheet.xls", 0)
Set xlSheet = xlWb.Worksheets("Sheet2")
Set xlWbA = xlApp.Workbooks.Open(xlApp.Application.LibraryPath & _
"\Analysis\atpvbaen.xla")
Set xlA = xlApp.AddIns.Add(xlApp.Application.LibraryPath &
"\Analysis\atpvbaen.xla")
xlA.Installed = True
xlSheet.Range("C1").Formula = "=NETWORKDAYS(A1,B1)"
xlWb.Save
xlWb.Close
xlWbA.Close
Set xlA = Nothing
Set xlSheet = Nothing
Set xlWb = Nothing
Set xlWbA = Nothing
Set xlApp = Nothing
xlApp.Quit
> It's giving me that error because the formula does not exist in excel when I
> open excel from access. It's easy to proove. When I open excel normally, I
[quoted text clipped - 68 lines]
> > > > > > >
> > > > > > > Is there any way around this?