ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   'null reference' when trying to use WorksheetFunction from C# (https://www.excelbanter.com/excel-worksheet-functions/84988-null-reference-when-trying-use-worksheetfunction-c.html)

RandomEngineer

'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?




All times are GMT +1. The time now is 04:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com