在 VBA (Visio) 中选择分组的形状
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9484774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Select grouped Shapes in VBA (Visio)
提问by dyesdyes
I'm trying to run through all the shapes of my current visio document using VBA to export some of the strings from it.
我正在尝试使用 VBA 遍历当前 visio 文档的所有形状,从中导出一些字符串。
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?
我将访问所有父形状。我想要的是访问孩子的形状。是否可以在不取消分组(父)形状的情况下访问它?
采纳答案by vulkanino
You can use the Shapes
property, i.e. vsoShape.Shapes(1).Name
.
您可以使用该Shapes
属性,即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