Managed C++ for Excel Add-in

M

My interest

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");
}
};
}
 
M

My interest

Sovled, it's registration problem. The default behavior of "register
output" seems to be different between C++ and C# projects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top