1
1

RotateMoveDuplicate.bas 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Attribute VB_Name = "RotateMoveDuplicate"
  2. Public Function move_shapes(x As Double, y As Double)
  3. On Error GoTo ErrorHandler
  4. API.BeginOpt
  5. Dim sr As ShapeRange '// 使用 ShapeRange 可以多个物件一起操作
  6. Set sr = ActiveSelectionRange '// 选择物件队列使用 ActiveSelectionRange
  7. sr.Move x, y '// 默认单位是 英寸 所以移动太远了
  8. ErrorHandler:
  9. API.EndOpt
  10. End Function
  11. Public Function Duplicate_shapes(x As Double, y As Double)
  12. On Error GoTo ErrorHandler
  13. API.BeginOpt
  14. Dim sr As ShapeRange
  15. Dim sr_copy As ShapeRange
  16. Set sr = ActiveSelectionRange
  17. Set sr_copy = sr.Duplicate(x, y) '// Duplicate 是再制,如果前面有 = 赋值,就要加上 (x,y)
  18. sr_copy.CreateSelection
  19. ErrorHandler:
  20. API.EndOpt
  21. End Function
  22. '// 批量旋转角度
  23. Public Function Shapes_Rotate(angle As Double)
  24. On Error GoTo ErrorHandler
  25. API.BeginOpt
  26. ActiveDocument.ReferencePoint = cdrCenter
  27. Dim sr As ShapeRange
  28. Set sr = ActiveSelectionRange
  29. For Each s In sr
  30. s.Rotate angle
  31. Next
  32. ErrorHandler:
  33. API.EndOpt
  34. End Function