473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# Excel Automation Add-In

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
6 14530
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
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
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dlakme | last post by:
Hi, I tried to add column headers and delete all rows to excel database which is a linked server to my sql server db. I got an error message, "delete data through linked server is not...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
1
by: Robinho | last post by:
Hi...i'm working on VB and I want open just Cells from excel, make a few operations, and save it like "work.xls" I don't want open excel, just see and work on cells predeterminates by me... ...
4
by: goonsquad | last post by:
I'm writing an Excel Automation app and I'm running to a problem early on with what should be a basic step. Dim oExcel As Object Dim oBook As Object Dim oSheet As Object Dim oRng As...
3
by: Mike | last post by:
Hello, I am attempting to export the contents of a datagrid on my webform (using Excel automation) through ASP.NET. I have added the Excel object library to my VS ASP.NET project but I am...
3
by: Gultekin Komanli | last post by:
Hi all, I'm new to .NET stuff and trying find a way to do automation with Excel, using VB 2005 EE. I searched this forum, there are samples that use some namespaces for office automation but...
0
by: mward | last post by:
I just upgraded my Office 2003 to SP2 and am having problems with my Excel automation code from C#. The version of Excel.exe that I'm now using is 11.0.8033.0. It appears as though the object...
3
by: Tim Marsden | last post by:
Hi, I am currently creating an instance of Excel using VB.NET Automation. dim xl as Excel.Application xl = new Excel.Application However, how can I have more control over the starting of...
18
by: John Bailo | last post by:
I want to write an Excel file (.xls format) from some database data. I don't want to use Excel.exe because of all the automation and security issues. Does Microsoft document the .xls file...
4
by: Keith Wilby | last post by:
How controllable from Access VBA is Excel? I'm currently using automation to dump 2 columns of data into an Excel spreadsheet so that the end user can create a line graph based on it. Could the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.