Advertisement

07.24.2007 at 02:45PM PDT, ID: 22718459
[x]
Attachment Details

Unable to call COM object written in C# from Excel

Asked by tridedave in .NET Framework 2.0, Windows ATL / WTL / COM Programming, Microsoft Programming

Tags: excel, call, from, com

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.InteropServices;

namespace ExcelTest
{
    [ComVisible(true), Guid("B74A3D2A-7F80-40b4-9398-FB4BAD0BF234"), ProgId("ExcelTest.Class1")]
    public class Class1
    {
        public Class1()
        {
        }

        public void Test()
        {
            System.Windows.Forms.MessageBox.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.Class1")
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?

ThanksStart Free Trial
 
Loading Advertisement...
 
[+][-]07.24.2007 at 03:54PM PDT, ID: 19560882

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 03:58AM PDT, ID: 19564219

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 05:07AM PDT, ID: 19564530

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 05:59AM PDT, ID: 19564904

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 06:23AM PDT, ID: 19565084

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 06:26AM PDT, ID: 19565106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 11:26AM PDT, ID: 19568337

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 11:32AM PDT, ID: 19568395

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Windows ATL / WTL / COM Programming, Microsoft Programming
Tags: excel, call, from, com
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.25.2007 at 12:01PM PDT, ID: 19568651

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.25.2007 at 02:16PM PDT, ID: 19569888

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32