Coding UDF's with VSTO

M

ma1achai

What is the best way to code UDF's for Excel using VSTO in VS 2008?

Are we still using an automation add-in through COM, or have they developed
a slicker way of exposing functions?

I noticed that if I'm using Excel Services (through SharePoint) that they
have a simple attribute that defines a function as an Excel UDF, as follows:
[UdfMethod(IsVolatile = true, ReturnsPersonalInformation = true)]

Is there something like that if you are not using SharePoint?
 
M

ma1achai

Thanks for the reply Chip. I was hoping that VSTO had made some sort of
evolutionary step forward and had a better way to do this now...

Also, when using the code:

<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> _
Public Class ExcelDivision

End Class

....doesn't this also expose the System.Object methods to Excel? I haven't
tried it, but I read that in a blog post by Gabhan Berry
(http://blogs.msdn.com/gabhan_berry/...xcel-worksheet-functions-in-c_2D00_sharp.aspx).
I was trying his method instead, but am having trouble figuring out how he
gets Excel to see his Functions class as an automation add-in. I tried and I
do not see it show up in the list.

Chip Pearson said:
Everything still has to go via COM, but see
http://www.cpearson.com/Excel/CreatingNETFunctionLib.aspx for examples of
creating a function lib in VB.NET.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





ma1achai said:
What is the best way to code UDF's for Excel using VSTO in VS 2008?

Are we still using an automation add-in through COM, or have they
developed
a slicker way of exposing functions?

I noticed that if I'm using Excel Services (through SharePoint) that they
have a simple attribute that defines a function as an Excel UDF, as
follows:
[UdfMethod(IsVolatile = true, ReturnsPersonalInformation = true)]

Is there something like that if you are not using SharePoint?
 
M

ma1achai

ok... it does look kie the System.Object methods are expoed as well... I can
see the following three in the Functions Wizard under my functions category:

Equal
GetHashCode
GetType
ToString

I can get rid of almost all of them by overriding the method and applying
the [ComVisible (false)] attribute. However, GetType is not override-able.
Any ideas on that one?

I'm still wondering how that addin from the blog works...


ma1achai said:
Thanks for the reply Chip. I was hoping that VSTO had made some sort of
evolutionary step forward and had a better way to do this now...

Also, when using the code:

<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> _
Public Class ExcelDivision

End Class

...doesn't this also expose the System.Object methods to Excel? I haven't
tried it, but I read that in a blog post by Gabhan Berry
(http://blogs.msdn.com/gabhan_berry/...xcel-worksheet-functions-in-c_2D00_sharp.aspx).
I was trying his method instead, but am having trouble figuring out how he
gets Excel to see his Functions class as an automation add-in. I tried and I
do not see it show up in the list.

Chip Pearson said:
Everything still has to go via COM, but see
http://www.cpearson.com/Excel/CreatingNETFunctionLib.aspx for examples of
creating a function lib in VB.NET.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





ma1achai said:
What is the best way to code UDF's for Excel using VSTO in VS 2008?

Are we still using an automation add-in through COM, or have they
developed
a slicker way of exposing functions?

I noticed that if I'm using Excel Services (through SharePoint) that they
have a simple attribute that defines a function as an Excel UDF, as
follows:
[UdfMethod(IsVolatile = true, ReturnsPersonalInformation = true)]

Is there something like that if you are not using SharePoint?
 

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