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 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago