Container List Members: who are they? where are they? Deletem!

Started by wapperdude, August 29, 2023, 05:31:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

Sometimes Lists are not intuitive (for me, for example).  I had an earlier version that exported List Members to Excel.  But, maybe you just want the list, or their X- / Y- Position, or perhaps you don't want them at all...just delete them.  The code below provides such a solution.  While it is for a  List type container, it could easily be modified for ordinary containers.

Note, the List shape identity is hardcoded in the macro.  Change this method.  It was unique to my test case.

Hope this is helpful.

Sub getListMbrs()

    Dim vListShp As Visio.Shape
    Dim listmembershape As Visio.Shape
    Dim arr As Variant
   
    ActiveWindow.DeselectAll

    Set vsoContainerShape = ActivePage.Shapes.ItemFromID(15)
    If vsoContainerShape.ContainerProperties.ContainerType = visContainerTypeList Then
'Search thru Attribute shapes
        arr = vsoContainerShape.ContainerProperties.GetListMembers
        Debug.Print "Number of List Items:  ", UBound(arr) + 1
        For i = 0 To UBound(arr)
            Set listmembershape = ActivePage.Shapes.ItemFromID(arr(i))

'Eliminate "Separator from list, it is 2D shape, with height = 0
            If listmembershape.Cells("Height").Result(none) > 0 Then
                Set vListShp = listmembershape
                ActiveWindow.Select vListShp, visSelect
                Debug.Print i, vListShp.NameU, vListShp.Text
'                Debug.Print "List Member Location: PinX / PinY:  ", vListShp.Cells("PinX").Result(none), " / ", vListShp.Cells("PinY").Result(none)
            Else
                m = m + 1   'modify row increment placement to avoid blanks for missing Separators
            End If
        Next
    End If
    Debug.Print "Number of List Members:  ", ActiveWindow.Selection.Count

'    ActiveWindow.Selection.Delete
   
End Sub
Visio 2019 Pro