473,395 Members | 1,623 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.

Using a C# class file as an Excel Automation add-in

Hi,

I've written the class below and compiled it with the 'Register for COM
Interop' option set to true and I can see the resulting .dll file.
However, I can not successfully pull it into the Add-in list from Excel
Tools Add-in Automation.
I tried copying code straight from this official Microsoft link:
http://msdn2.microsoft.com/en-us/library/ms173189.aspx

I have also tried installing the following patch:
http://msdn2.microsoft.com/en-us/library/ms173189.aspx

I am using MS Office Professional 2003 with a complete installation of
Excel, .NET Framework 2.0 and Microsoft Visual C# Express Edition, and
I'd imported the Excel 5.0 Object Library as a project reference.

I'd really appreciate some help as am quite stuck.

Thank you in advance.

Regards,
Schiz

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Text;

namespace CSharpAddIn
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Functions
{
public Functions()
{
}

public double NormDensity(double x)
{
return Math.Exp(-x * x * 0.5) / Math.Sqrt(2 * Math.PI);

}

//Stuff to deal with the registry below
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(
GetSubKeyName(type));
}

[ComUnregisterFunctionAttribute]
public static void UnRegisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(
GetSubKeyName(type), false);
}

private static string GetSubKeyName(Type type)
{
StringBuilder subKeyName = new StringBuilder();
subKeyName.Append(@"CLSID\{");
subKeyName.Append(type.GUID.ToString().ToUpper());
subKeyName.Append(@"}\Programmable");
return subKeyName.ToString();
}
}

}

Jan 20 '07 #1
0 1253

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
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: RJN | last post by:
Hi I've a template excel file which has all the calculations defined. There are certain input values to be entered which gives a lot of output to the user. I don't want to expose the excel sheet...
4
by: Agnes | last post by:
I searched from previous post and got that there is a solution which export the data to export without using Excel auotmation. However, my database is SQL server, How can I amend...
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...
9
by: John Bailo | last post by:
I want to generate 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...
6
by: Karl | last post by:
Hi all, It may seem like a rather odd request (or not) but I would like to be able to create a file (doc, jpg, xls or one of many other files that can be automated) on a website and stream it to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.