How to easily create an Excel UDF with VSTO Add-in project

前端 未结 4 2112
日久生厌
日久生厌 2020-12-25 13:22

What I am trying to do is to create User Defined Functions (UDFs) for Excel using VSTO’s C# “Excel 2007 Add-in”-project type (since I just want to generate some general UDFs

4条回答
  •  青春惊慌失措
    2020-12-25 13:53

    What I've found that works well is to keep the UDF as a VB module to avoid the issues with COM objects.

    I've got tons of C# code running and when I'm ready to build the release I do the following:
    1. Add a module:
       Developer [tab in Excel] | Visual Basic -> project window, right-click, insert module
       - merely copy/paste the VB code here
    2. Include the appropriate reference library (Tools in same VB window)
    3. Save the Excel file as an .xlsm (ie, Macro-Enabled)

    You can then delete the .xlsx file.

    What I do is zip the entire directory (eg, "Release") and send it to our users.

提交回复
热议问题