View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RandomEngineer
 
Posts: n/a
Default 'null reference' when trying to use WorksheetFunction from C#

I've got Microsoft.Office.Interop.Excel referenced in a .NET 2.0 class. No
problems with compilation but at runtime, I get 'null reference' errors when
trying to use an Excel function.

For example,
using Excel = Microsoft.Office.Interop.Excel;
Excel.WorksheetFunction wsFunction = null;
double weibull = wsFunction.Weibull(1, 2, 3, true);

I receive the 'null reference' error on the wsFunction.Weibull call.

I've also tried...
internal Excel.Application ThisApplication
{
get { return thisApplication; }
}
private Excel.Application thisApplication = null;
double weibull = thisApplication.WorksheetFunction.Weibull(1, 2, 3, true);

and receive the same error when trying to use a WorksheetFunction call.

Any ideas?