Managed C++ for Excel Add-in



I was able to create an automation Add-in for Excel using C#. But I
was unable to do the same in Managed C++ (VS2005). The code posted
below is almost a direct translation from C# to C++. Build was OK, and
I could see MyTest.Fun in the Excel Add-In list (in the exact same way
as if the code was written in C#), but I could not the the function
(i.e. not show in the Function help list and will show #Name if I type
in =IsOK()

I guess I may just missed one small thing that is specific to C++, but
I couldn't figure it out. Anybody who can help? (Or is it because C++
does not support this mechanism at all?)

My code:

--------------------------

#using <mscorlib.dll>

using namespace System;
using namespace System::Runtime::InteropServices;

namespace MyTest
{
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public ref class Fun
{
public:

Fun() {}

public:

double IsOK(void)
{
return 1234.567;
}

public:

[ComRegisterFunctionAttribute]
static void RegisterFunction(Type^ t)
{

Microsoft::Win32::Registry::ClassesRoot->CreateSubKey("CLSID\\{" +
t->GUID.ToString()->ToUpper() + "}\\Programmable");
}

[ComUnregisterFunctionAttribute]
static void UnregisterFunction(Type^ t)
{

Microsoft::Win32::Registry::ClassesRoot->DeleteSubKey("CLSID\\{" +
t->GUID.ToString()->ToUpper() + "}\\Programmable");
}
};
}

.



Relevant Pages

  • RE: UDF limits
    ... and how to use multiple UDF in one Excel cell. ... For the first question about how to add a UDF to a COM Addin, first off, I ... or convert the COM addin to an automation add-in: ... automation addins only support "Load on Demand". ...
    (microsoft.public.excel.programming)
  • Re: How to use automation Add-In to replace Excel macros!!
    ... "Tom Ogilvy" wrote: ... > was to restrict the the cells operated on to those with the function. ... >> The strange thing is any new excel sheet, the functions from the DLL works ... >> Binding for functions in an Automation Add-in is at the end of the ...
    (microsoft.public.excel.programming)
  • Re: VB.NET: How to declare a parameter in a worksheet-function
    ... To debug the code, close Excel and then open your solution in Visual ... to Tools then Add-Ins and uncheck the NET automation add-in. ... Public Shared Sub RegisterFunction(ByVal ...
    (microsoft.public.excel.programming)
  • Re: Order of Excel Add-ins.
    ... Why dont you get the automation add-in to open the XLA itself rather than ... Decision Models ... FastExcel 2.1 now available ... > in (every time restarting Excel). ...
    (microsoft.public.excel.programming)
  • Creating control in a threadpool thread slows down Excel startup ( bug in framework?).
    ... Below is a small application which recreates a problem we found in one ... you double-click on an Excel file. ... private static void CallbackTarget ... If you try to start Excel by double clicking on an Excel file while the ...
    (microsoft.public.dotnet.csharp.general)