Private Sub AlignHorizontal(ARate As Single)
Dim Min, Max, i As Integer
Min = 32768
Max = -32768
For Each AShape In Selection.ChildShapeRange
If Min > AShape.Left Then
Min = AShape.Left
End If
i = AShape.Left + AShape.Width / 20
If Max < i Then
Max = i
End If
Next AShape
For Each AShape In Selection.ChildShapeRange
AShape.Left = Min * (1 - ARate) + Max * ARate - AShape.Width / 20 * ARate
Next AShape
End Sub
Private Sub AlignVertical(ARate As Single)
Dim Min, Max, i As Integer
Min = 32768
Max = -32768
For Each AShape In Selection.ChildShapeRange
If Min > AShape.Top Then
Min = AShape.Top
End If
i = AShape.Top + AShape.Height / 20
If Max < i Then
Max = i
End If
Next AShape
For Each AShape In Selection.ChildShapeRange
AShape.Top = Min * (1 - ARate) + Max * ARate - AShape.Height / 20 * ARate
Next AShape
End Sub
Private Sub AlignShape(AHorizontal As Boolean, ARate As Single)
If Selection.ChildShapeRange.Count = 0 Then
Exit Sub
End If
If AHorizontal Then
AlignHorizontal (ARate)
Else
AlignVertical (ARate)
End If
End Sub
Sub AlignHorizontalLeft()
AlignShape True, 0
End Sub
Sub AlignHorizontalCenter()
AlignShape True, 0.5
End Sub
Sub AlignHorizontalRight()
AlignShape True, 1
End Sub
Sub AlignVerticalTop()
AlignShape False, 0
End Sub
Sub AlignVerticalMiddle()
AlignShape False, 0.5
End Sub
Sub AlignVerticalBottom()
AlignShape False, 1
End Sub