UsedObjects Members

Use the UsedObjects collection to get a mixed collection of all of the objects currently loaded in Excel. The UsedObjects collection has the following members :

Application
Count
Creator
Item
Parent

The following code displays a list of all the objects loaded in Excel. The code uses error handling to skip over properties not available for the different types of objects included in the UsedObjects collection:

Sub ShowObjects(  )
    Dim obj As Object, str As String
    On Error Resume Next
    Debug.Print "Type", "Name", "ProgID"
    For Each obj In Application.UsedObjects
        str = TypeName(obj)
        str = str & vbTab & obj.Name
        str = str & vbTab & obj.progID
        Debug.Print str
    Next
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.