ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF for Excel in C# paramters not coming through (https://www.excelbanter.com/excel-programming/380157-udf-excel-c-paramters-not-coming-through.html)

Nico[_3_]

UDF for Excel in C# paramters not coming through
 
Hello,

I'm trying to get a UDF written in C# to work.

Thanks to the excellent article from Eric Carter you'll get a flying
start.
"user defined functions for Excel in .NET"
http://blogs.msdn.com/eric_carter/ar...01/273127.aspx

But when I use the function in Excel as described I get the known
#VALUE! result ;o(
When I debug I see that the parameters from Excel are not coming
through, they remain null.
When I add a function without parameters, I get result.

It gets more strange because the breakpoints do not work "anymore" on
function MultiplyNTimes, the worked at least once ;o)
On every other function I add I can create breakpoints but still no
parameters coming through ;o)

f.i.:
public double Add(object Number1, object Number2)
{
double result = 0;
Excel.Range r1 = Number1 as Excel.Range;
Excel.Range r2 = Number2 as Excel.Range;

result = Convert.ToDouble(r1.Value2) +
Convert.ToDouble(r1.Value2);

return result;
}


I'm just starting to play with c#, any clues highly appreciated!

Thx!



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

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