我正在尝试使用VBA运行当前visio文档的所有形状,以从中导出一些字符串。
看起来很简单,但我不知道如何获得分组的形状。
通过做:
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
我将访问所有父形状。我想要的是访问孩子们的形状。 是否可以在不取消分组(父)形状的情况下访问它?
答案 0 :(得分:2)
您可以使用Shapes
属性,即vsoShape.Shapes(1).Name
。
完整循环:
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