Sub CenterObjects()'center_objects1Dim OrigSelection As ShapeRangeSet OrigSelection = ActiveSelectionRangeOrigSelection(2).AlignToShape cdrAlignHCenter + cdrAlignVCenter, OrigSelection(1), cdrTextAlignBoundingBoxEnd Sub
Only two objects are accepting to make it center... if i select more... then this macro not working.
please update
Hello, I can't understand exactly what you want. Try this. I hope it works for you.
Sub Center_selected_shapes_to_page_center()'ActiveDocument.ActiveLayer.Shapes.All.AlignToPageCenter (cdrAlignVCenter)ActiveSelection.Shapes.All.AlignToPageCenter (cdrAlignVCenter)ActiveSelection.Shapes.All.AlignToPageCenter (cdrAlignHCenter)End Sub
firstset i selected one object and later selected the another single element, then the above script is working. if i have select the muliple object at second time.... then the above script is not working
Hello,I understand, that You select first one object - suppose with name Object1.After that You select other objects - 1 - 2 - 3 etc. You wont that all other objects are centered to Object1?Greetings!
yes
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 shapeDim first_shape As ShapeDim OrigSelection As ShapeRangeSet OrigSelection = ActiveSelectionRangeSet first_shape = OrigSelection(1)'first_shape.Fill.UniformColor.RGBAssign 255, 0, 0For X = 2 To OrigSelection.Shapes.Count'OrigSelection(X).Fill.UniformColor.RGBAssign 255, 0, 0'all shapes will be centered to last selected shapeOrigSelection(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), cdrTextAlignBoundingBoxNextEnd Sub