简体   繁体   中英

C# and Excel automation Add-in problems

I'm kind of new to c# and trying to create an automation add-in for excel and I followed the instructions given in this article

This is working fine when I use numbers as parameters to the function called from a cell

 =MultiplyNTimes(3,7,8)

but when I use cell addresses

=MultiplyNTimes(A1,B2,C3)

excel doesn't recognize the function and it throws the #NAME error.

Debugging in VS, I can see that the function is not even called.

Just guessing, but the first thing I would try is to to change the function parameters for

public double MultiplyNTimes(double number1, double number2, double timesToMultiply)

to

public double MultiplyNTimes(Excel.Range number1, Excel.Range number2, Excel.Range timesToMultiply)

..to get it to accept worksheet cell addresses instead of numeric values.

不太优雅,但是请尝试以下操作:

=MultiplyNTimes(VALUE(A1),VALUE(B2),VALUE(C3))

I recently used this article and was able to debug the code using Excel 2007 and VS 2010. From the project settings, Debug > Start External program > Excel.exe.

Excel 2003 isn't supoorted in VS2010 not sure if that is causing the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM