Hi John, thanks for the help. I can use the piece of code you gave me
to find the count, so I know it works. One thing that is still
confusing me is how to loop through the group members. I've got the
following:
Dim cmd As Visio.Shape
Dim mem As Visio.Shape
Dim con As Visio.Connects
Debug.Print cmd.Shapes.Count
Set cmd = ActivePage.Shapes("Sheet.675")
For Each shp in cmd
Set con = shp.Connects
Next shp
---
I am getting compilation errors. I thought setting the group variable
to a Visio.Shapes type would make more sense seeing as how there are
multiple shapes, but when I did that it wouldn't even let me do the
debug.print. Do you know any possible sources for the error?
cmd is a shapes collection so should be dim'd as Visio.Shapes
Since Shapes can contain shapes you will have to add a touch of recursion.
Public Sub ConnectionsList()
Dim vsoSelect As Visio.Selection
Dim vsoShape As Visio.Shape
Dim vsoShapes As Visio.Shapes
Set vsoSelect = Visio.ActiveWindow.Selection
Debug.Print vsoSelect.Count
If vsoSelect.Count > 0 Then
'For each shape in the selection, get its connections.
For Each vsoShape In vsoSelect
Call ProcessShape(shp)
Next vsoShape
Else
MsgBox "You Must Have Something Selected"
End If
End Sub
Public Sub ProcessShape(shp As Visio.Shape)
Dim subshp As Visio.Shape
Dim vsoConnect As Visio.Connect
Dim vsoConnects As Visio.Connects
Debug.Print shp.Name
Set vsoConnects = vsoShape.Connects
'For each connection, get the shape it connects to.
For Each vsoConnect In vsoConnects
'Print the name of the shape the
'Connect object connects to.
Debug.Print vsoShape.Name; " connects to "; vsoConnect.ToSheet.Name
Next vsoConnect
If shp.Shapes.Count > 0 Then
For Each subshp In shp.Shapes
Call ProcessShape(subshp )
Next subshp
End If
End Sub
John... Visio MVP