F
Fredrik Wahlgren
Hi
I found an interesting piece of code which shows how to makee an Excel
automation add-in at http://www.codeproject.com/dotnet/excelnetauto.asp. I
decide to experiment with it and i made a few changes. I now have a method
that takes an Excel.Range as a parameter. My problem now is that when I use
Excel's function wizard, there are thre more functions available, namely
ToString, GetHashCode & GetType. I don't want them. How can I get rid of
them?
BTW. Can someone explain the difference between Range and IRange. The former
is a dispinterface while the latter is an interface in the idl file that i
have generated. In what scenarios do you use IRange?
TIA,
Fredrik
Here's my modified code.
using System;
using System.Runtime.InteropServices;
using Excel;
// using Excel = Microsoft.Office.Interop.Excel;
namespace NAddIn
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Functions
{
public Functions()
{
}
public int GetRangeSize(Excel.Range range)
{
return range.Columns.Count * range.Rows.Count;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
I found an interesting piece of code which shows how to makee an Excel
automation add-in at http://www.codeproject.com/dotnet/excelnetauto.asp. I
decide to experiment with it and i made a few changes. I now have a method
that takes an Excel.Range as a parameter. My problem now is that when I use
Excel's function wizard, there are thre more functions available, namely
ToString, GetHashCode & GetType. I don't want them. How can I get rid of
them?
BTW. Can someone explain the difference between Range and IRange. The former
is a dispinterface while the latter is an interface in the idl file that i
have generated. In what scenarios do you use IRange?
TIA,
Fredrik
Here's my modified code.
using System;
using System.Runtime.InteropServices;
using Excel;
// using Excel = Microsoft.Office.Interop.Excel;
namespace NAddIn
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Functions
{
public Functions()
{
}
public int GetRangeSize(Excel.Range range)
{
return range.Columns.Count * range.Rows.Count;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}