+ Reply to Thread
Results 1 to 3 of 3

Shapes and VBA in Excel 2000 and 2002

Hybrid View

  1. #1
    TV
    Guest

    Shapes and VBA in Excel 2000 and 2002

    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

  2. #2
    Nick Hebb
    Guest

    Re: Shapes and VBA in Excel 2000 and 2002

    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".


  3. #3
    TV
    Guest

    Re: Shapes and VBA in Excel 2000 and 2002

    "Nick Hebb" <n.hebb@comcast.net> wrote in message news:<1118332807.737601.4300@g43g2000cwa.googlegroups.com>...
    > 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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1