- 精华
- 活跃值
-
- 积分
- 161
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:47 天 连续签到:0 天
|
Dim arr() As Double
Sub 水平间距对齐()'其实就是 AIt +a +a ......
Dim s As Shape, news As New ShapeRange, i As Integer, max1 As Double, min1 As Double, k As Integer, k1 As Integer
If ActiveSelection.Shapes.Count > 2 Then '大于2才运行下面代码
ActiveDocument.Unit = CDRMillimeter
i = -1
ReDim arr(0 To ActiveSelectionRange.Shapes.Count - 1, 4)
For Each s In ActiveSelectionRange.Shapes
i = i + 1
arr(i, 0) = s.LeftX
arr(i, 1) = s.BottomY
arr(i, 2) = i
s.GetSize arr(i, 3), arr(i, 4)
news.Add s
Next
shuzupaixu arr '数组排序
max1 = max() '获取最大x坐标
min1 = min() '获取最小x坐标
spac1 = spac(max1, min1) '获取间距
spacfirst = max1 - min1
For i = 1 To UBound(arr()) - 1
k = arr(i, 2) + 1
k1 = arr(i - 1, 2) + 1
news.Shapes(k).LeftX = news.Shapes(k1).LeftX + arr(i - 1, 3) + spac1
Next
End If
End Sub
Function shuzupaixu(arr() As Double) '数组排序
For i = 1 To UBound(arr())
For j = i + 1 To UBound(arr()) + 1
d1 = arr(i - 1, 0)
d2 = arr(j - 1, 0)
If d1 > d2 Then
t = arr(j - 1, 0) 's的leftx
t1 = arr(j - 1, 1) 's的bottomy
t2 = arr(j - 1, 2) 's的index
t3 = arr(j - 1, 3) 's的width
t4 = arr(j - 1, 4) 's的height
arr(j - 1, 0) = arr(i - 1, 0)
arr(j - 1, 1) = arr(i - 1, 1)
arr(j - 1, 2) = arr(i - 1, 2)
arr(j - 1, 3) = arr(i - 1, 3)
arr(j - 1, 4) = arr(i - 1, 4)
arr(i - 1, 0) = t
arr(i - 1, 1) = t1
arr(i - 1, 2) = t2
arr(i - 1, 3) = t3
arr(i - 1, 4) = t4
End If
Next j
Next i
End Function
Function spac(max1 As Double, min1 As Double) '获取间距
spac = max1 - min1 - arr(0, 3)
For i = 1 To UBound(arr()) - 1
spac = spac - arr(i, 3)
Next
spac = spac / UBound(arr())
End Function
Function max() As Double '获取最大值 其实就是第一个
x = arr(0, 0)
For i = 1 To UBound(arr())
y = arr(i, 0)
max = IIf(x > y, x, y)
Next
End Function
Function min() As Double '获取最小值 其实就是第二个
x = arr(0, 0)
For i = 1 To UBound(arr())
y = arr(i, 0)
min = IIf(x < y, x, y)
Next
End Function
|
|