I am trying to use the For Each...Next looping structure with a User Defined Class and a corresponding User defined Collection Class.
From the Help files on F E...N -
"For collections, element can only be a Variant variable, a generic object variable, or any specific object variable. "
Based on this, I assumed I would be able to use this structure with UD classes, but I can't make it happen. I keep getting the "Object doesn't support this property or method (Error 438)" error.

Here's a slimmed down version of my class, collection and a code snippet demonstrating the error.

As always - any help is appreciated.

Sample Module Code
VB Code:
  1. Sub TryTests()
  2. Dim MyTests As cTests
  3. Dim i As Integer
  4. Dim MyTest As cTest
  5.    
  6.     Set MyTests = New cTests
  7.     For i = 1 To 5
  8.         MyTests.Add "Test" & CStr(i)
  9.     Next i
  10.    
  11.     'This loop structure doesn't work
  12.     For Each MyTest In MyTests
  13.         Debug.Print MyTest.Name
  14.     Next MyTest
  15.    
  16.     Set MyTest = Nothing
  17.     Set MyTests = Nothing
  18. End Sub

"cTest" Class Code
VB Code:
  1. Private pNAME As String
  2.  
  3. Property Get Name() As String
  4.     Name = pNAME
  5. End Property
  6.  
  7. Property Let Name(nName As String)
  8.     pNAME = nName
  9. End Property

"cTests" Collection Class Code
VB Code:
  1. Private pCol As Collection
  2.  
  3. Private Sub Class_Initialize()
  4.     Set pCol = New Collection
  5. End Sub
  6.  
  7. Private Sub Class_Terminate()
  8.     Set pCol = Nothing
  9. End Sub
  10.  
  11. Function Add(TestName As String) As cTest
  12. Dim NewItem As New cTest
  13.    
  14.     NewItem.Name = TestName
  15.    
  16.     pCol.Add Item:=NewItem, key:=TestName
  17.     Set Add = NewItem
  18.    
  19.     Set NewItem = Nothing
  20. End Function