Tools.bas 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Attribute VB_Name = "Tools"
  2. '// This is free and unencumbered software released into the public domain.
  3. '// For more information, please refer to https://github.com/hongwenjun
  4. '// 简易火车排列
  5. Public Function Simple_Train_Arrangement(Space_Width As Double)
  6. API.BeginOpt
  7. Dim ssr As ShapeRange, s As Shape
  8. Dim cnt As Integer
  9. Set ssr = ActiveSelectionRange
  10. cnt = 1
  11. #If VBA7 Then
  12. ' ssr.sort " @shape1.top>@shape2.top"
  13. ssr.Sort " @shape1.left<@shape2.left"
  14. #Else
  15. ' X4 不支持 ShapeRange.sort 使用 lyvba32.dll 算法库排序 2023.07.08
  16. Set ssr = X4_Sort_ShapeRange(ssr, stlx)
  17. #End If
  18. ActiveDocument.ReferencePoint = cdrTopLeft
  19. For Each s In ssr
  20. '// 底对齐 If cnt > 1 Then s.SetPosition ssr(cnt - 1).RightX, ssr(cnt - 1).BottomY
  21. '// 改成顶对齐 2022-08-10
  22. ActiveDocument.ReferencePoint = cdrTopLeft + cdrBottomTop
  23. If cnt > 1 Then s.SetPosition ssr(cnt - 1).RightX + Space_Width, ssr(cnt - 1).topY
  24. cnt = cnt + 1
  25. Next s
  26. API.EndOpt
  27. End Function
  28. '// 简易阶梯排列
  29. Public Function Simple_Ladder_Arrangement(Space_Width As Double)
  30. API.BeginOpt
  31. Dim ssr As ShapeRange, s As Shape
  32. Dim cnt As Integer
  33. Set ssr = ActiveSelectionRange
  34. cnt = 1
  35. #If VBA7 Then
  36. ssr.Sort " @shape1.top>@shape2.top"
  37. #Else
  38. ' X4 不支持 ShapeRange.sort 使用 lyvba32.dll 算法库排序 2023.07.08
  39. Set ssr = X4_Sort_ShapeRange(ssr, stty).ReverseRange
  40. #End If
  41. ActiveDocument.ReferencePoint = cdrTopLeft
  42. For Each s In ssr
  43. If cnt > 1 Then s.SetPosition ssr(cnt - 1).LeftX, ssr(cnt - 1).BottomY - Space_Width
  44. cnt = cnt + 1
  45. Next s
  46. API.EndOpt
  47. End Function