PDA

View Full Version : Solved: Excel ShapeRange.Align



wagnet
03-04-2009, 01:41 PM
I have Groups containing 3 shapes each. The group's Shape.Name contains the word "Cabinet". I want to msoAlignLeft all of the shapes within the Group...but, alas, I must not have the structure figured out.....thought it would be something like this.... Any help appreciated!

Sub AlignWithinGroup()
'************************************************************************** ************
'*** Align all shapes within the Group
'************************************************************************** ************
Dim shp As Shape, j As Integer, i As Integer
j = ActiveSheet.Shapes.Count
For i = 1 To j
If InStr(ActiveSheet.Shapes(i).Name, "Cabinet") > 0 Then
ActiveSheet.Shapes(i).Select
With ActiveSheet.Shapes(i)
With .GroupItems.Select
Selection.ShapeRange.Align msoAlignLefts, False
End With
End With
End If
Next i
End Sub

Sample worksheet with Grouped shapes has been uploaded.
Typically, there will be one to twenty grouped shapes with a maximum of several hundred.

I figured it out. The .Align only seems to work on ungrouped shapes, so first I needed to .Ungroup then .Align then regroup.

mdmackillop
03-04-2009, 01:59 PM
Can you post a sample?