Please update this macro

Sub CenterObjects()
'center_objects1
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection(2).AlignToShape cdrAlignHCenter + cdrAlignVCenter, OrigSelection(1), cdrTextAlignBoundingBox
End Sub

Only two objects are accepting to make it center... if i select more... then this macro not working.

please update 

Parents
No Data
Reply
  • Hello,
    Here is my improved code.
    All selected shapes will be centered to last selected shape

    Sub BhBp_CenterObjects()

    'all shapes will be centered to last selected shape
    Dim first_shape As Shape
    Dim OrigSelection As ShapeRange
    Set OrigSelection = ActiveSelectionRange
    Set first_shape = OrigSelection(1)
    'first_shape.Fill.UniformColor.RGBAssign 255, 0, 0
    For X = 2 To OrigSelection.Shapes.Count
    'OrigSelection(X).Fill.UniformColor.RGBAssign 255, 0, 0
    'all shapes will be centered to last selected shape
    OrigSelection(X).AlignToShape cdrAlignHCenter + cdrAlignVCenter, OrigSelection(1), cdrTextAlignBoundingBox
    'all shapes will be centered to first selected shape
    'OrigSelection(X).AlignToShape cdrAlignHCenter + cdrAlignVCenter, OrigSelection(OrigSelection.Shapes.Count), cdrTextAlignBoundingBox
    Next
    End Sub

Children
No Data