Custom Scripting Dictionary Class
I am working on an Excel VBA app that will use several custom classes that encapsulate a Scripting.Dictionary. I wish to use the For Each construct with these classes. I have put together the class and entered the NewEnum function, exported the class, added the necessary Attribute records, re-imported the class. The class works quite well except the For Each gets an error 424 Object required error. I have been unable to find any information about using NewEnum with an encapsulated Dictionary. Here is some sample code:
Option Explicit
Private mdictShtRegns As Scripting.Dictionary
Public Sub Add(ByRef inObject As cSheetRegion)
mdictShtRegns.Add inObject.Name, inObject
End Sub
Public Property Get Count() As Long
Count = mdictShtRegns.Count
End Property
Public Property Get Item(ByVal vIndex As Variant) As cSheetRegion
Set Item = mdictShtRegns.Item(vIndex)
End Property
Public Function NewEnum() As IUnknown
Set NewEnum = mdictShtRegns.Items.[_NewEnum]
End Function
Private Sub Class_Initialize()
Set mdictShtRegns = New Scripting.Dictionary
End Sub
As noted above, a standard module creates and populates the object well, I just can't use For Each with it.
VW
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago