REPLACE SHAPES

Hello,
Please help with VBA code

I have 2 shapes in upper left corner of picture above. I select 2 shapes and start SUB REPLACE()

Arrows show a necessary result
Rectangle replace ellipse or
Ellipse replace rectangle
Greetings!
 

Parents
  • Use the macro below.
    It replaces all selected shapes with the last selected object.

    Sub Macro1()
        Dim s As Shape, s1 As Shape, s2 As Shape, SR As ShapeRange

        Set SR = ActiveSelectionRange

        Set s1 = SR.Shapes.First
        s1.RemoveFromSelection

        Set SR = ActiveSelectionRange
        For Each s In SR
            Set s2 = s1.Duplicate
            s2.CenterX = s.CenterX
            s2.CenterY = s.CenterY
        Next s

        SR.Delete
    End Sub

Reply Children
No Data