Access .NET class library from Excel 97

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pete Kane

    Access .NET class library from Excel 97

    Hi All, does anyone know if it's possible to utilise a .NET class
    library from Excel 97 ? I've tried but receive a runtime error
    -2146232576 which means nothing to me, my class is shown below, I've
    placed the assembly into the GAC and registered it using RegAsm all to
    no avail

    using System;
    using System.Collecti ons.Generic;
    using System.Text;
    using System.IO;
    using System.Runtime. InteropServices ;

    namespace CallingCSharpFr omWord97
    {

    [ComVisible(true )]
    public class PJKWordClass
    {
    public TextWriter tw = null;

    public PJKWordClass()
    {
    }

    public void WriteLogFile(st ring msg)
    {
    tw = new StreamWriter("c :\\PJKCalledFro mWord97.log", true);
    tw.WriteLine(St ring.Format("Th is file was created by C# which was
    called from a COM client {0} at
    {1}",msg,DateTi me.Now.ToLongDa teString()));
    tw.Close();
    }

    }
    }


    I can reference the assembly in Excel, but when run, it bombs on the
    CreateObject line ( with the error number shown above )

    Dim oCSharp As CallingCSharpFr omWord97.PJKWor dClass

    Set oCSharp = CreateObject("C allingCSharpFro mWord97.PJKWord Class")

    regards

    n.b. I can successfuly use the class from other clients , Visual Foxpro
    for instance
Working...