Reputation: 33071
I have a spreadsheet that is using the WORKDAY() function in Excel (which I believe lives in the Analysis Toolpak library/package/whatever you call it in Excel). When I open this spreadsheet manually and call this function it behaves fine.
I have a macro that references the cell that the WORKDAY() function is used in:
Dim startDate as Date
startDate = Cells(1,1)
When I run the macro after opening the spreadsheet manually this code executes fine. The problem is when I try and open the spreadsheet and run the macro from my C# code. It will then fail when it tries to get the value for startDate. When I look at that cell I see a #VALUE! reference error. It seems like it is not loading the correct references when I open the spreadsheet from my C# code.
Does anyone know how to resolve this issue?
Upvotes: 2
Views: 602
Reputation: 29244
What I had to do is force the loading of the .xla
add-in using:
app.Workbooks.Open(file_name)
where app
is an instance of Microsoft.Office.Interop.Excel.Application
if it already open then nothing happens, otherwise it loads the analysis addin. To find the path for the add-in it depends on the version of Office
Upvotes: 3