private void buttonSameHeightOrWidth_Click(object sender, RibbonControlEventArgs e) { try { PowerPoint.Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; HeightOrWidth heightOrWidth = e.Control.Id == btnSameHeight.Id ? HeightOrWidth.Height : HeightOrWidth.Width; ToolsSizeAndPosition.SameHeightOrWidth(selection, heightOrWidth); } catch (Exception ex) { Exceptions.Handle(ex); } }
public static void SameHeightOrWidth(PowerPoint.Selection selection, HeightOrWidth heightOrWidth) { foreach (PowerPoint.Shape shape in selection.ShapeRange) { if (heightOrWidth == HeightOrWidth.Height) { shape.Height = selection.ShapeRange[1].Height; } else { shape.Width = selection.ShapeRange[1].Width; } } }