Where a custom data type does have to be declared for further use?
Neither in a explicitly included module nor in a shared module can't we avoid the following error message:
'Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types'
What is a public object module in the context of TestPartner?
Thanks in advance for your help
I think its the main module your code is in.
Seeing your code that throws this error would be helpful.
Thanks for your reply.
I've found an answer to my question.
My aim was to define a custom data type and then to add objects of this type to a collection.
Since this is not possibly the error is being thrown. It is a VBA limitation.
I have to declare a class instead of the type and adding instances of this class to the collection works fine.
If you place it in the Shared Module it works fine as a custom type with no other references or includes.
Shared Module:<font class="small">Code:</font><hr /><pre>
Public Type xyz
x As Integer
y As String
z As Boolean
End Type</pre><hr />
Test Script:<font class="small">Code:</font><hr /><pre>Sub Main()
Dim customType As xyz
customType.x = 1
customType.y = "hello"
customType.z = True
End Sub</pre><hr />
A problem is a difference between what is perceived and what is desired, that
we want to reduce (Dewey 1933)