'null reference' when trying to use WorksheetFunction from C#

G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top