title: Excel 2007 UDF: how to add function description, argument help?
body: <h2>The description</h2>
  
  <p>I am writing a couple of Excel UDFs in COM Servers. I'd like to get the standard help (<em>Insert Function</em> dialog) that you get when you press <em>fx</em>. Yes, I can see my COM Server listed in among the Category drop down, but</p>
  
  <ul>
  <li>I also see Equals, GetHashCode, GetType, and ToString (which are fairly undesirable to expose to the Excel user), </li>
  <li>selecting my COM Server brings up the *Function Arguments*[1] dialog with no argument information and no description of the function.</li>
  </ul>
  
  <p>Here is the lameness that I get:</p>
  
  <p><a href="http://www.iwebthereforeiam.com/files/Insert%20function%20dialog.gif" rel="nofollow noreferrer">Insert Function dialog http://www.iwebthereforeiam.com/files/Insert%20function%20dialog.gif</a></p>
  
  <p><a href="http://www.iwebthereforeiam.com/files/Function%20Arguments%20dialog.gif" rel="nofollow noreferrer">Excel Function Arguments dialog http://www.iwebthereforeiam.com/files/Function%20Arguments%20dialog.gif</a></p>
  
  <h2>The question</h2>
  
  <p>Are there .NET attributes I could put on the methods to pass this through to Excel?</p>
  
  <ul>
  <li>Can I provide a description of the function?</li>
  <li>Can I provide a description of the parameters?</li>
  <li>Can I provide a category name for my functions, so that I get something better than just the ProgID?</li>
  </ul>
  
  <p>(I see that it looks sadly easy to do in ExcelDNA, but I am not going that route. Emulating govert's code [custom attributes, a loader of some sort, etc.] looks like it would be pretty hard.)</p>
  
  <hr>
  
  <h2>Additional background</h2>
  
  <p>If you have not done work with Excel + COM Servers before, here are some useful resources to get up to speed:</p>
  
  <p>Previous StackOverflow questions:<br>
  <a href="https://stackoverflow.com/questions/1506858/how-to-get-com-server-for-excel-written-in-vb-net-installed-and-registered-in-aut">How to get COM Server for Excel written in VB.NET installed and registered in Automation Servers list?</a><br>
  <a href="https://stackoverflow.com/questions/742851/how-add-a-com-exposed-net-project-to-the-vb6-or-vba-references-dialog">How Add a COM-Exposed .NET Project to the VB6 (or VBA) References Dialog?</a>  </p>
  
  <p>Other resources:<br>
  <a href="http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx" rel="nofollow noreferrer">Writing user defined functions for Excel in .NET</a><br>
  <a href="http://www.simple-talk.com/dotnet/visual-studio/build-and-deploy-a-.net-com-assembly/" rel="nofollow noreferrer">Build and Deploy a .NET COM Assembly</a><br>
  <a href="http://blogs.msdn.com/gabhan_berry/archive/2008/04/07/writing-custom-excel-worksheet-functions-in-c_2D00_sharp.aspx" rel="nofollow noreferrer">Writing Custom Excel Worksheet Functions in C#</a>  </p>
  
  <hr>
  
  <p>Edit 2009-10-20 14:10</p>
  
  <p>I tried out calling <code>Application.MacroOptions</code> in a <code>Sub New()</code>. </p>
  
  <ol>
  <li>No Sub New()<br />
  Semi-acceptable: Function is listed under category ProgID.</li>
  <li>Shared Sub New()<br />
  Not acceptable: build-time error.<blockquote><pre>Cannot register assembly "...\Foo.dll".
  Exception has been thrown by the target of an invocation.</pre></blockquote></li>
  <li>Sub New()<br />
  Not acceptable: category is not listed in Insert Function dialog.</li>
  </ol>
  
  <p>I suspect this is a problem both for MacroOptions and for the more involved route recommended by Charles.</p>
  
  <hr>
  
  <p>Edit 2009-10-20 14:55</p>
  
  <p>On the plus side, Mike's recommendation to create an interface to implement did kill off the annoying extra methods that were exposed.</p>
  
  <hr>
  
  <p>Edit 2009-10-20 15:00</p>
  
  <p><a href="http://support.microsoft.com/kb/285337/" rel="nofollow noreferrer">This Microsoft article</a> from early 2007 (via <a href="http://blogs.msdn.com/andreww/archive/2008/01/23/managed-automation-add-ins.aspx" rel="nofollow noreferrer">Mike's link</a>) seems a rather complete answer on the topic:</p>
  
  <blockquote>
    <p>Automation Add-ins and the Function
    Wizard</p>
    
    <p>Each Automation Add-in has its own
    category in the Excel Function Wizard.
    The category name is the ProgID for
    the Add-in; you cannot specify a
    different category name for Automation
    Add-in functions. Additionally, there
    is no way to specify function
    descriptions, argument descriptions,
    or help for Automation Add-in
    functions in the Function Wizard.</p>
  </blockquote>
  
  <hr>
  
  <p><a href="http://www.iwebthereforeiam.com/files/Insert%20function%20dialog.gif" rel="nofollow noreferrer">1</a> Huh, a StackOverFlow bug. It looks like you cannot italicize a string inside an explicit HTML ul-list?</p>