Step:1 :- CREATE THE C# PROJECT(Class lib Application)
Step:2 :- Set the project properties Register for COM Interop to TRUE
#region Using Directives //Using Interop services
using System;
using System.Runtime.InteropServices;
namespace NewAddInFunctionality
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class AddINFunctions
{
public AddINFunctions()
{
}
Add Method
public double Add2(double v1, double v2)
{
return v1 + v2;
}
Multiply Method
public double Multiply(double v1, double v2)
{
return v1 * v2;
}
Divide Method
public double Divide(double v1, double v2)
{
return v1 * v2;
}
Mod Method
public double MOD(double v1, double v2)
{
return v1 % v2;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type funType)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + funType.GUID.ToString().ToUpper() +
"}\\Programmable");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type funType)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + funType.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
Step :3 Build the Project Get the DLL
Step :4 GO To Excel and Open a WorkBook
Step : ADDINS select methods and type ADD(3 + 7) then result will be 10
Step:2 :- Set the project properties Register for COM Interop to TRUE
#region Using Directives //Using Interop services
using System;
using System.Runtime.InteropServices;
namespace NewAddInFunctionality
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class AddINFunctions
{
public AddINFunctions()
{
}
Add Method
public double Add2(double v1, double v2)
{
return v1 + v2;
}
Multiply Method
public double Multiply(double v1, double v2)
{
return v1 * v2;
}
Divide Method
public double Divide(double v1, double v2)
{
return v1 * v2;
}
Mod Method
public double MOD(double v1, double v2)
{
return v1 % v2;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type funType)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + funType.GUID.ToString().ToUpper() +
"}\\Programmable");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type funType)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + funType.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
Step :3 Build the Project Get the DLL
Step :4 GO To Excel and Open a WorkBook
Step : ADDINS select methods and type ADD(3 + 7) then result will be 10