Selection.GetContainers Method (Visio)
Returns an array of shape identifiers (IDs) of the container shapes in the selection.
The NestedOptions parameter must be one of the following VisContainerNested constants.
Include shapes that are in nested containers.
Exclude shapes that are in nested containers..
You can use the Shapes.ItemFromID property to get the actual shapes from the IDs returned by GetContainers.