I was to use code written in C# from an Excel VBA Function. I have written a simple c# object like this:
using System;
using System.Collections.Generic
;
using System.Text;
using System.Runtime.InteropServ
ices;
namespace ExcelTest
{
[ComVisible(true), Guid("B74A3D2A-7F80-40b4-9
398-FB4BAD
0BF234"), ProgId("ExcelTest.Class1")
]
public class Class1
{
public Class1()
{
}
public void Test()
{
System.Windows.Forms.Messa
geBox.Show
("Its working", "Yay!");
}
}
}
I am building it from Visual Studio 2005, and I checked the register for COM interop check box in the build properties. I wrote a test VBS file that looks like this:
Dim FooObj
Set FooObj = CreateObject("ExcelTest.Cl
ass1")
FooObj.Test
The test VBS file works fine, but if I put the same code in an excel module and try to step through the code, execution of the function stops when CreateObject is called.
Does anybody know why it doesn't work from Excel or does somebody have suggestions on how I can trouble shoot this?
Thanks
Start Free Trial