当我遍历" Full_Banner" 的GroupItem时,我的代码会在红色方块中返回下面每个项目的名称。
我想要的是我的代码返回蓝色方块中每个项目的名称(见下文)。我怎么能这样做呢?
Sub Get_Shape_Name()
For Each element In ActiveSheet.Shapes("Full_Banner").GroupItems
MsgBox element.Name
Next
End Sub
答案 0 :(得分:2)
我不知道任何访问子组名称的方法。作为解决方法,您可以取消组合形状,列出所有组项并将形状分组:
Sub Get_Shape_Name()
Dim aShape As Shape
Dim rShape As ShapeRange
Const sName As String = "Full_Banner"
Set rShape = ActiveSheet.Shapes(sName).Ungroup
For Each aShape In rShape
If aShape.ShapeStyle = msoShapeMixed Then
MsgBox aShape.Name
End If
Next
rShape.Group.Name = sName
End Sub