T
TV
I have a large amount of shape-groups that I want to manipulate by
VBA.
All the groups are basicly the same structure and consists of several
other shape-groups. So my structure looks something like this
(simplified):
Group "Group AA1" contains groups named: "Subgroup SS1" and "Subgroup
SS2" each containing shapes named: "Line1" and "Line2"
Group "Group AA2" also contains groups named: "Subgroup SS1" and
"Subgroup SS2" each again containing shapes named: "Line1" and "Line2"
The task is to access a specific subgroup whitin a maingroup - and
return this group as a shape-object.
This code works in Xl 2000:
-----
Public Function SubShape(ByVal ParentShape As Shape, sID As String) As
Shape
Dim i As Integer
With ParentShape
For i = 1 To .GroupItems.Count 'Evaluates to 2
If .GroupItems(i).Name = sID Then
Set SubShape = .GroupItems(i)
Exit For
End If
Next i
End With
End Function
---------
Sub ShapeTest()
Dim AllShapes As Shapes
Dim MainShape As Shape
Dim MyShape As Shape
Set AllShapes = ActiveSheet.Shapes
Set MainShape = AllShapes("Group AA1")
Set MyShape = SubShape(MainShape, "Subgroup SS1")
End Sub
BUT in Xl 2002 (v10):
GroupItems.Count evalutes to 4 (Number of lines) and it is not
possible - or is it - to return the embedded shape-group.
ANY idea to overcome the problem - preferebly in a way that works both
in Xl2000 and Xl2002 - and maybe even in a later version.
Deadline is closing so any help appreciated.
Thomas Voetmann
VBA.
All the groups are basicly the same structure and consists of several
other shape-groups. So my structure looks something like this
(simplified):
Group "Group AA1" contains groups named: "Subgroup SS1" and "Subgroup
SS2" each containing shapes named: "Line1" and "Line2"
Group "Group AA2" also contains groups named: "Subgroup SS1" and
"Subgroup SS2" each again containing shapes named: "Line1" and "Line2"
The task is to access a specific subgroup whitin a maingroup - and
return this group as a shape-object.
This code works in Xl 2000:
-----
Public Function SubShape(ByVal ParentShape As Shape, sID As String) As
Shape
Dim i As Integer
With ParentShape
For i = 1 To .GroupItems.Count 'Evaluates to 2
If .GroupItems(i).Name = sID Then
Set SubShape = .GroupItems(i)
Exit For
End If
Next i
End With
End Function
---------
Sub ShapeTest()
Dim AllShapes As Shapes
Dim MainShape As Shape
Dim MyShape As Shape
Set AllShapes = ActiveSheet.Shapes
Set MainShape = AllShapes("Group AA1")
Set MyShape = SubShape(MainShape, "Subgroup SS1")
End Sub
BUT in Xl 2002 (v10):
GroupItems.Count evalutes to 4 (Number of lines) and it is not
possible - or is it - to return the embedded shape-group.
ANY idea to overcome the problem - preferebly in a way that works both
in Xl2000 and Xl2002 - and maybe even in a later version.
Deadline is closing so any help appreciated.
Thomas Voetmann