Shapes and VBA in Excel 2000 and 2002

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
 
N

Nick Hebb

Hate to tell you this, but your functions worked fine for me in Excel
2002, SP3. It's tough to troubleshoot

What service pack do you have?

Also, I think the Count is immaterial since you are testing each shape
for the Name. But if you want to ship testing Lines then you could
wrap the inner code with "If .GroupItems(i).AutoShapeType <> -2 Then".
 
T

TV

Nick Hebb said:
Hate to tell you this, but your functions worked fine for me in Excel
2002, SP3. It's tough to troubleshoot

What service pack do you have?

Have tested it in SP0 and SP3 - same problem
Also, I think the Count is immaterial since you are testing each shape
for the Name. But if you want to ship testing Lines then you could
wrap the inner code with "If .GroupItems(i).AutoShapeType <> -2 Then".

Great idear to use AutoShapeType, but
in Excel 2000 I get two groupitems, each has AutoShapeType -2 and
named Subgroup SS1 and Subgroup SS2
in Excel XP I get four groupitems, each has also AutoShapeType -2 and
named Line 1 etc.
I am confused - dont know about you.

I also tried the parrent property without luck.

Thanks anyway.

Thomas Voetmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top