123456789101112131415161718192021222324252627282930313233343536373839 |
- Attribute VB_Name = "AverageDistance"
- Public AutoDistribute_Key As Boolean
- Public first_StaticID As Long
- '// Ñ¡ÔñµÄÎï¼þƽ¾ù¾àÀë
- Public Function Average_Distance()
- On Error GoTo ErrorHandler
- API.BeginOpt
-
- Dim sr As ShapeRange
- Set sr = ActiveSelectionRange
- sr.Sort "@shape1.left<@shape2.left"
- Distribute_Shapes sr
-
- ErrorHandler:
- API.EndOpt
- End Function
- Private Function Distribute_Shapes(sr As ShapeRange)
- Dim first As Double, last As Double
- Dim interval As Double, currentPoint As Double
- Dim total As Integer
- Dim sh As Shape
-
- first_StaticID = sr.FirstShape.StaticID
- total = sr.Count
- first = sr.FirstShape.CenterX
- last = sr.LastShape.CenterX
- interval = (last - first) / (total - 1)
- currentPoint = first
- For Each sh In sr
- sh.CenterY = sr.FirstShape.CenterY
- sh.CenterX = currentPoint
- currentPoint = currentPoint + interval
- Next sh
- End Function
|