views:

996

answers:

2

I'd like to be able to call a function exposed by a VSTO addin from a cell in an excel worksheet. More specifically, if I have a VSTO function Foo() that returns "bar" I'd like to be able to write =Foo() in A1 which evaluates to "bar" on calculation.

Is this possible? What are the key steps I'd need to take?

The prospect of being able to leverage managed code and the VS08 IDE for excel development is very appealing. I thought VSTO would allow me to easily do this but I'm no longer sure. Am I misunderstanding the architecture here? The documentation is a little shoddy.

+1  A: 

I don't believe you can do so directly, though you can use a VBA wrapper, see for example http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx.

You can also use a third party product like ManagedXll to create Excel UDFs in managed code.

Joe
A: 

I think you can make use of COM Interop.. here is a webpage where I've seen the process described.

http://www.cpearson.com/excel/creatingnetfunctionlib.aspx

Jeff