The problem about Excel automation add-ins.
-
Excel enables the creation of user-defined functions that can be used in Excel formulas. So I use these code to create a COM introp. ------------------------------------------------- using System; using System.Runtime.InteropServices; using Microsoft.Win32; namespace AutomationAddin { [ClassInterface(ClassInterfaceType.AutoDual)] public class MyFunctions { public MyFunctions() { } public double MultiplyNTimes(double number1, double number2, double timesToMultiply) { double result = number1; for (double i = 0; i < timesToMultiply; i++) { result = result * number2; } return result; } [ComRegisterFunctionAttribute] public static void RegisterFunction(Type type) { Registry.ClassesRoot.CreateSubKey( GetSubKeyName(type)); } [ComUnregisterFunctionAttribute] public static void UnregisterFunction(Type type) { Registry.ClassesRoot.DeleteSubKey( GetSubKeyName(type), false); } private static string GetSubKeyName(Type type) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append(@"CLSID\{"); s.Append(type.GUID.ToString().ToUpper()); s.Append(@"}\Programmable"); return s.ToString(); } } } ----------------------------------------------------- And set project build property,checked output item,register COM interop. Building the project,that's success. Launch Excel and choose Add-Ins from the Tools menu to display the Add-Ins dialog. In the Add-Ins dialog, click the Automation button. But I can't find the class I created by looking for AutomationAddin.MyFunctions in the list of automation servers. What's wrong? Please help me !Thanks,by the way,My development tool is VS2005 ,Office 2003 (sp2)simply chinese.