Iterating through the Object Browser in VBA

前端 未结 5 1402
抹茶落季
抹茶落季 2021-01-03 05:43

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?

5条回答
  •  耶瑟儿~
    2021-01-03 06:14

    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
    

提交回复
热议问题