Consulting

Results 1 to 3 of 3

Thread: Comparing Shape Properties in a Group

  1. #1

    Comparing Shape Properties in a Group

    Hey everyone. I am trying to write a program that allows the user to define the space between two shapes. When I try to run the program I get an error that says "Method or Data Member Not Found" when I use .Group. I am relatively new to VBA but have experience working in the C++ environment. The code:

    Sub Spacer()
    
    
    Dim sel As GroupShapes
    Dim TopShape As Shape
    Dim BottomShape As Shape
    Dim Space As Single
    Dim x As Single
    
    
    sel = ActiveWindow.Selection.ShapeRange(1).Group
    If sel.Item(1) > sel.Item(2) Then
        TopShape = sel.Item(1)
        BottomShape = sel.Item(2)
    Else
        TopShape = sel.Item(2)
        BottomShape = sel.Item(1)
    End If
    
    
    Space = TopShape.Height - BottomShape.Height
    x = InputBox("Bottom Space:")
    For i = Space To x
        BottomShape.IncrementTop 1
        i = TopShape.Height - BottomShape.Height
    Next i
    
    
    End Sub
    Anyone have any ideas why the Group does not work? Also, if you have any other pointers or ideas, let me know!

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I'm not sure, but looking at this line, makes me wonder which Group.Item Property is being compared. It may not be numerical.
    If sel.Item(1) > sel.Item(2) Then
    I kinda suspect that if you specified which Property you were comparing, it might work. ie:
    If sel.Item(1).Width > sel.Item(2).Width Then


    In any case, this will bump your thread back to the top. I also re titled this thread to, IMO, better intice somebody who does know PowerPoint.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Sub Spacer()
    
       Dim sel As GroupShapes
       Dim TopShape As Shape
       Dim BottomShape As Shape
       Dim Space As Single
       Dim x As Single
       On Error Resume Next
       If ActiveWindow.Selection.ShapeRange(1).Type <> msoGroup Then Exit Sub
       Set sel = ActiveWindow.Selection.ShapeRange(1).GroupItems
       If sel.Item(1).Top > sel.Item(2).Top Then
          Set TopShape = sel.Item(2)
          Set BottomShape = sel.Item(1)
       Else
          Set TopShape = sel.Item(1)
          Set BottomShape = sel.Item(2)
       End If
       x = InputBox("Bottom Space:")
       Space = (TopShape.Top + TopShape.Height) - (BottomShape.Top)
       BottomShape.Top = TopShape.Top + TopShape.Height + x
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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