c# enumerable class - compatible with VBA
Try adding [DispId(-4)]
to your GetEnumerator()
method. This flags it to be the DISPID_NEWENUM
member. In order for VBA to work with a collection using For Each, it needs to implement _newEnum via COM.
This can be done by implementing an Enumerator and attributing it with the proper DispId. This is typically done via implementing a custom interface with this specified, though there are other mechanisms available.