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 resultRectangle replace ellipse orEllipse replace rectangleGreetings!
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.DeleteEnd Sub
I think that is a very good approach. One advantage of the way you are doing it is that it allows one to use some other tool - e.g., CorelDRAW's "Find" capability, or the Select Same macro - to help prepare the selection before running the macro.
Another thing you could add would be something to help maintain the stacking order:
s2.OrderFrontOf s
When I wrote the macro, the question of stacking order did not arise for me. I need to replace all the selected shapes and the macro does it. But the color, shape type, angle of shape rotation etc - up to you. I agree Eskimo that your ideas are interesting.