View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
akash akash is offline
external usenet poster
 
Posts: 3
Default "Object Required" error when calling .Net DLL

I have a simple .Net 2.0 class which I am trying to access from Excel
(Office XP).

<InterfaceType(ComInterfaceType.InterfaceIsDual) _
Public Interface IComClass
Property Value() As Object
End Interface

<ClassInterface(ClassInterfaceType.None) _
Public Class ComClass
Implements IComClass
Public Property Value() As Object Implements IComClass.Value
Get
Return Me._Value
End Get
Set(ByVal value As Object)
Me._Value = value
End Set
End Property
Private _Value As Object

Public Sub New()
Me._Value = 1234
End Sub
End Class

I have produced the .tlb, registered the class and added the
apprioriate reference in VBA. However, when I try to run the following
code I get an "object required" error at the line ' CC.Value = "abcd"
'

Dim CC As New ComClass
MsgBox (CC.Value)
CC.Value = "abcd"
MsgBox CC.Value

Any idea what I am missing?

Thanks
Akash