Search code examples
vbaclassms-accessmembertlbinf32

Iterating through the Object Browser in VBA


I would like to iterate through members of any class in a referenced library much like is done using the Object Browser. How can this be done using VBA?


Solution

  • I found a KB from Microsoft which allowed me to do just that. It also covers iteration over Member details as well.

    Private Sub ListClassesInAccess()        
        Dim TypeLibrary As TypeLibInfo
        Dim ClassList As CoClasses
        Dim i As Integer    
        Dim Path As String
        Path = "C:\Program Files\Microsoft Office\OFFICE11\MSACC.OLB"
    
        Set TypeLibrary = TypeLibInfoFromFile(Path)
        Set ClassList = TypeLibrary.CoClasses
    
        For i = 1 To ClassList.Count
            MsgBox ClassList.Item(i).Name     
        Next
    
        Set TypeLibrary = Nothing
        Set ClassList = Nothing
    End Sub