I have a situation where a VB.Net COM Class in not inheriting functions accessible to the parent class when accessing the interface via VBA.
I.e. I have a VB.Net COM Class (myParent) and a VB.net COM Subclass (myChild).
I have searched and found something similar here: Exposing inherited members of a COM vb.net class but the solution "try this" did not seem to exist?
<ComClass(MyParent.ClassId, MyParent.InterfaceId, MyParent.EventsId)>
Public Class MyParent
#Region "COM GUIDs"
Public Const ClassId As String = "386e628c-872b-41ee-abb2-d2a5dfb4e51e"
Public Const InterfaceId As String = "f4b194f1-9dc9-4f37-93d8-57cb97e05593"
Public Const EventsId As String = "4320826d-a02c-4360-b8b5-4c98569c2b2e"
#End Region
Public Sub New()
MyBase.New()
End Sub
Public Function parent_hello_world() As Boolean
MsgBox("Hello from Parent")
Return True
End Function
End Class
<ComClass(MyChild.ClassId, MyChild.InterfaceId, MyChild.EventsId)>
Public Class MyChild
Inherits MyParent
#Region "COM GUIDs"
Public Const ClassId As String = "65674d29-7bb7-447e-8282-47b9873cec4a"
Public Const InterfaceId As String = "cbcdfb17-c8b9-42e2-bed7-b516b9df6111"
Public Const EventsId As String = "22a8959c-7594-4584-b53d-a087246be623"
#End Region
Public Sub New()
MyBase.New()
End Sub
Public Function child_hello_world() As Boolean
MsgBox("Hello from Child")
Return True
End Function
End Class
And the below code (when executed from VBA) fails:
Sub test_me()
Dim tip As New TestInheritance.MyParent
Dim tic As New TestInheritance.MyChild
tip.parent_hello_world() 'this works - directly from parent
tic.child_hello_world() 'this works - child function
tic.parent_hello_world() 'throws an error - not accessible?
End Sub
Is there any solution for this aside from needing to redefine the interfaces in the child class?
Thanks so much.