By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,139 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,139 IT Pros & Developers. It's quick & easy.

Calling a C# assembly from Excel or Word (VBA) => Automation Error

P: n/a

I have tried the example from the KB article 817248
( in Visual Basic AND in C# with
..NET Framework 2.0:

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Public Const ClassId As String = "6DB79AF2-F661-44AC-8458-62B06BFDD9E4"
Public Const InterfaceId As String = "EDED909C-9271-4670-BA32-109AE917B1D7"
Public Const EventsId As String = "17C731B8-CE61-4B5F-B114-10F3E46153AC"

Public Sub New()
End Sub

Public Function myFunction() As Integer
Return 100
End Function

End Class

Then I registered the assembly with regasm.exe and the options "/tlb:
TestProj /codebase". Everything worked great if I called the function from
Visual Basic 6:

Dim myObject As TestProj.COMClass1
Set myObject = New TestProj.COMClass1
MsgBox myObject.myFunction

If I try to call exactly the same code from VBA in Excel or Word I get an
automation error at line "Set myObject = New TestProj.COMClass1" saying that
the assembly is not found (I have added the reference of course). If I try it
in VBA of MS Access it works, too. With .NET 1.1 it works in Excel and in
Word with no errors, but I need it under .NET 2.0.

Can somebody help me please?
Thanks a lot in advance,


Apr 3 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.