I have the following VBA code (late binding):
Dim myList As Object
Set myList = CreateObject("System.Collections.SortedList")
which I want to replace with this (early binding):
Dim myList As New SortedList
Has anyone succeeded with this? I suppose that A reference must be enabled. But what is the name of that reference?
Probably* the easiest way is to add it on openning:
Private Sub Workbook_Open()
With ThisWorkbook.VBProject.References
.AddFromFile "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb"
'.AddFromguid "{BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}", 2, 4
End With
End Sub
This adds the mscorlib.dll
to the references:
And then:
Public Sub TestMe()
Dim myList As SortedList
Dim myList2 As New ArrayList ' as a bonus!
End Sub
From http://www.snb-vba.eu/VBA_Sortedlist_en.html
\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb
or in a comparable directory