How to create an Excel automation add-in using C#

E

Emmanuel

Hi,

I want to create an Excel automation add-in using VS.NET C#.
I' ve found only one article written by Govert van Drimmelen:
http://www.codeproject.com/dotnet/excelnetauto.asp

The problem is that although the code is very simple when I try to load the
add-in I get
the error message: "Cannot find add-in 'mscoree.dll'. Delete from list".

I am using VS.NET 2003 and MS Office 2003.

Please help


Emmnauel

===================

Bellow follows the code

===================

using System;
using System.Runtime.InteropServices;

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

public double Add2(double v1, double v2)
{
return v1 + v2;
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
 
F

Fredrik Wahlgren

Funny, I downloaded the same sample yesterday and I couldn't make it work
either. I have the Swedish version of Excel. I think there are two possible
reasons.

1) In a different codeproject article, i think, there was a comment that
stated that some pice of code had to be changed so that the dll could be
found. I think this is the most likely reason why the add-in won't work

2) I also found something that led me to belive I had to set some language
code in the dll. It was called something like CulturalXXX

/ Fredrik
 
E

Emmanuel

Hi Fredik,

After a while I discovered that the function Add2() (if you answer "No" to
the "Delete from list ?" question)
works fine.

Unfortunatelly the problem with mscoree.dll remains.

What did you find that led you to believe that Cultural settings are
involved ?

Emmanuel

Fredrik Wahlgren said:
Funny, I downloaded the same sample yesterday and I couldn't make it work
either. I have the Swedish version of Excel. I think there are two
possible
reasons.

1) In a different codeproject article, i think, there was a comment that
stated that some pice of code had to be changed so that the dll could be
found. I think this is the most likely reason why the add-in won't work

2) I also found something that led me to belive I had to set some language
code in the dll. It was called something like CulturalXXX

/ Fredrik


Emmanuel said:
Hi,

I want to create an Excel automation add-in using VS.NET C#.
I' ve found only one article written by Govert van Drimmelen:
http://www.codeproject.com/dotnet/excelnetauto.asp

The problem is that although the code is very simple when I try to load the
add-in I get
the error message: "Cannot find add-in 'mscoree.dll'. Delete from list".

I am using VS.NET 2003 and MS Office 2003.

Please help


Emmnauel

===================

Bellow follows the code

===================

using System;
using System.Runtime.InteropServices;

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

public double Add2(double v1, double v2)
{
return v1 + v2;
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
 
F

Fredrik Wahlgren

Hi

Strange, the Add2 function now works. I started excel and wanted to make
sure the add-in was loaded as an automation add-in. ISuddenly, Excel said
there were two copies of mscoree.dll. Then it hang so I chose to restart it.
Now, I could use Add2. I browsed several articles in codeproject and in one
article - I don't know which - there was a comment about cultural settings.
I didn't pay enough attention but I remebered it when add2 didn't work on
first attempt.


Emmanuel said:
Hi Fredik,

After a while I discovered that the function Add2() (if you answer "No" to
the "Delete from list ?" question)
works fine.

Unfortunatelly the problem with mscoree.dll remains.

What did you find that led you to believe that Cultural settings are
involved ?

Emmanuel

Funny, I downloaded the same sample yesterday and I couldn't make it work
either. I have the Swedish version of Excel. I think there are two
possible
reasons.

1) In a different codeproject article, i think, there was a comment that
stated that some pice of code had to be changed so that the dll could be
found. I think this is the most likely reason why the add-in won't work

2) I also found something that led me to belive I had to set some language
code in the dll. It was called something like CulturalXXX

/ Fredrik


Emmanuel said:
Hi,

I want to create an Excel automation add-in using VS.NET C#.
I' ve found only one article written by Govert van Drimmelen:
http://www.codeproject.com/dotnet/excelnetauto.asp

The problem is that although the code is very simple when I try to load the
add-in I get
the error message: "Cannot find add-in 'mscoree.dll'. Delete from list".

I am using VS.NET 2003 and MS Office 2003.

Please help


Emmnauel

===================

Bellow follows the code

===================

using System;
using System.Runtime.InteropServices;

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

public double Add2(double v1, double v2)
{
return v1 + v2;
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\Programmable");
}
}
}
 

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