By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

C# Excel Automation Add-In

P: n/a
Excel 2002 introduced a capability to add custom worksheet functions to
Excel direct from a COM/ActiveX object.

I can use C# to develop a COM object which I can use fine from Excel/VBA,
however I can't see it using the Excel Tools/Add-Ins - Automation button.

Now this appears to be because it is not an *ActiveX* COM object, apparently
in order to be an ActiveX object the COM object needs to have a
'CLSID'/Programmable key entry in the registry.

I can add this Key myself in regedt32 and then the C# COM object works fine
as an Automation Add-in. But I'm sure this isn't the correct way to do it,
so is there a C#/.Net attribute or something to create the "Programmable"
registry key automatically?

Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You need to run RegAsm.exe on the C# assembly, just as you would need to run
RegSrv32.exe on unmanaged COM libraries for them to be registered properly
in the system registry.
The installation/deployment projects should do this step for you as part of
the installation process for your component.
You can use the RegistrationServices class if you want to register other
components from code at runtime. In addition, you can create a function in
your component and apply the ComRegisterFunctionAttribute to it if you want
to insert custom registry entries (with the Microsoft.win32.Registry class)
when RegAsm is executed against your component.

Also, there's registration-free COM interop, which you might want take a
look at:
http://msdn.microsoft.com/library/en...asp?frame=true
It's got some limitations and other special steps involved, so read
carefully.

-Rob Teixeira [MVP]

"Frank X" <Fr**********@yahoo.ie> wrote in message
news:c1*************@ID-103389.news.uni-berlin.de...
Excel 2002 introduced a capability to add custom worksheet functions to
Excel direct from a COM/ActiveX object.

I can use C# to develop a COM object which I can use fine from Excel/VBA,
however I can't see it using the Excel Tools/Add-Ins - Automation button.

Now this appears to be because it is not an *ActiveX* COM object, apparently in order to be an ActiveX object the COM object needs to have a
'CLSID'/Programmable key entry in the registry.

I can add this Key myself in regedt32 and then the C# COM object works fine as an Automation Add-in. But I'm sure this isn't the correct way to do it,
so is there a C#/.Net attribute or something to create the "Programmable"
registry key automatically?

Nov 15 '05 #2

P: n/a
I think you are missing the point, the COM object is registered
automatically by Visual Studio as part of the build process (I think it
automatically calls regasm.exe). The COM object is registered OK and is
usable from Excel/VBA. This isn't my problem.

However I want to use the server as an Excel "Automation Add-in" (meaning I
don't need a VBA wrapper function), this requires the COM component to be an
ActiveX component, apparently a COM component only becomes an ActiveX
component if it has the registry key /CLSID/'guid'/Programmable.

It is only the /CLSID/'guid'/Programmable key that is missing and I was
hoping I could just add an attribute to my C# file to cause regasm.exe to
create it automatically.

Please forgive me if I have misunderstood, I am relatively ignorant of this
stuff.
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
You need to run RegAsm.exe on the C# assembly, just as you would need to run RegSrv32.exe on unmanaged COM libraries for them to be registered properly
in the system registry.
The installation/deployment projects should do this step for you as part of the installation process for your component.
You can use the RegistrationServices class if you want to register other
components from code at runtime. In addition, you can create a function in
your component and apply the ComRegisterFunctionAttribute to it if you want to insert custom registry entries (with the Microsoft.win32.Registry class) when RegAsm is executed against your component.

Also, there's registration-free COM interop, which you might want take a
look at:
http://msdn.microsoft.com/library/en...stration-freec
ominterop.asp?frame=true It's got some limitations and other special steps involved, so read
carefully.

-Rob Teixeira [MVP]

"Frank X" <Fr**********@yahoo.ie> wrote in message
news:c1*************@ID-103389.news.uni-berlin.de...
Excel 2002 introduced a capability to add custom worksheet functions to
Excel direct from a COM/ActiveX object.

I can use C# to develop a COM object which I can use fine from Excel/VBA, however I can't see it using the Excel Tools/Add-Ins - Automation button.
Now this appears to be because it is not an *ActiveX* COM object,

apparently
in order to be an ActiveX object the COM object needs to have a
'CLSID'/Programmable key entry in the registry.

I can add this Key myself in regedt32 and then the C# COM object works

fine
as an Automation Add-in. But I'm sure this isn't the correct way to do it, so is there a C#/.Net attribute or something to create the "Programmable" registry key automatically?


Nov 15 '05 #3

P: n/a
Actually, ActiveX is a bit of a marketing term for COM components that
support automation.
If all you need is the programmable key, my advice about adding a custom
registration function and tagging it with the ComRegisterFunctionAttribute
will work. Just create the key inside that function using the
Microsoft.Win32.Registry class.

-Rob Teixeira [MVP]
"Frank X" <Fr**********@yahoo.ie> wrote in message
news:c1*************@ID-103389.news.uni-berlin.de...
I think you are missing the point, the COM object is registered
automatically by Visual Studio as part of the build process (I think it
automatically calls regasm.exe). The COM object is registered OK and is
usable from Excel/VBA. This isn't my problem.

However I want to use the server as an Excel "Automation Add-in" (meaning I don't need a VBA wrapper function), this requires the COM component to be an ActiveX component, apparently a COM component only becomes an ActiveX
component if it has the registry key /CLSID/'guid'/Programmable.

It is only the /CLSID/'guid'/Programmable key that is missing and I was
hoping I could just add an attribute to my C# file to cause regasm.exe to
create it automatically.

Please forgive me if I have misunderstood, I am relatively ignorant of this stuff.

Nov 15 '05 #4

P: n/a
AcitveX, Automation, Programmable, Ol2e Tomatas Tomatoes, Potatats Potatoes,
lets call the whole thing off :o)

All I know is that if I don't have the Programmable key in the registry
Excel doesn't list the Components and if I do it does.

I will have a look at the ComRegisterFunctionAttribute, but was hoping to
find a simpler route. All I really want is the quickest way to develop addin
worksheet functions, mainly for my own consumption, instead of using VBA.

I certainly wouldn't be using this stuff for wide scale distribution yet, I
almost got fired for recommending COM Excel addins which, proved v. dodgy,
back in 96.

Thanks for your help.
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl...
Actually, ActiveX is a bit of a marketing term for COM components that
support automation.
If all you need is the programmable key, my advice about adding a custom
registration function and tagging it with the ComRegisterFunctionAttribute
will work. Just create the key inside that function using the
Microsoft.Win32.Registry class.

-Rob Teixeira [MVP]
"Frank X" <Fr**********@yahoo.ie> wrote in message
news:c1*************@ID-103389.news.uni-berlin.de...
I think you are missing the point, the COM object is registered
automatically by Visual Studio as part of the build process (I think it
automatically calls regasm.exe). The COM object is registered OK and is
usable from Excel/VBA. This isn't my problem.

However I want to use the server as an Excel "Automation Add-in" (meaning
I
don't need a VBA wrapper function), this requires the COM component to
be an
ActiveX component, apparently a COM component only becomes an ActiveX
component if it has the registry key /CLSID/'guid'/Programmable.

It is only the /CLSID/'guid'/Programmable key that is missing and I was
hoping I could just add an attribute to my C# file to cause regasm.exe

to create it automatically.

Please forgive me if I have misunderstood, I am relatively ignorant of

this
stuff.


Nov 15 '05 #5

P: n/a
Along this same line.. can anyone definitively tell me how to create an add-in for excel with a function that can be called from cells as part of a forumula? I have been searching for days and it seems like nobody does this. This threah is the closest thing Ive found to it. I followed the example for creating a COM addin using VB.NET and it works fine, but is not visible in the addin list and public functions within it are not visible to cells. Help!
Nov 16 '05 #6

P: n/a
"Jason Rodman" <an*******@discussions.microsoft.com> wrote:
Along this same line.. can anyone definitively tell me how to create an

add-in for excel with a function that can be called from cells as part of a
forumula? I have been searching for days and it seems like nobody does this.
This threah is the closest thing Ive found to it.

Jason,

I can't find the thread you are referring to, but have a look at
http://ManagedXLL.net/
Jens.
--
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.