dyesdyes
dyesdyes

Reputation: 1217

Select grouped Shapes in VBA (Visio)

I'm trying to run through all the shapes of my current visio document using VBA to export some of the strings from it.

It seems easy but I don't know how to get the grouped shapes.

By doing:

Dim vsoShapes AS Visio.Shapes
Dim vsoShape AS Visio.Shape
Set vsoShapes = Application.ActiveWindow.Page.Shapes
For Each vsoShape In vsoShapes
  ' my code
  ' my code
Next

I'm going to access all the parent shapes. What I want is accessing the shapes of the children. Is it possible to access it without ungrouping the grouped (parent) shape?

Upvotes: 2

Views: 8291

Answers (1)

vulkanino
vulkanino

Reputation: 9124

You can use the Shapes property, i.e. vsoShape.Shapes(1).Name.

Full loop:

Dim vsoShapes AS Visio.Shapes
Dim vsoShape AS Visio.Shape
Dim i As Integer
Dim shapeCount As Integer

Set vsoShapes = Application.ActiveWindow.Page.Shapes
For Each vsoShape In vsoShapes
  shapeCount = vsoShape.Shapes.Count
  If shapeCount > 1 Then
    i = 1
    For i = 1 To shapeCount
      MsgBox vsoShape.Shapes(i).Text
    Next i
  End If
Next

Upvotes: 2

Related Questions