1
1

API.bas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Attribute VB_Name = "API"
  2. Public Function GetSet(s As String)
  3. Bleed = Val(GetSetting("262235.xyz", "Settings", "Bleed", "2.0"))
  4. Line_len = Val(GetSetting("262235.xyz", "Settings", "Line_len", "3.0"))
  5. Outline_Width = Val(GetSetting("262235.xyz", "Settings", "Outline_Width", "0.2"))
  6. ' Debug.Print Bleed, Line_len, Outline_Width
  7. If s = "Bleed" Then
  8. GetSet = Bleed
  9. ElseIf s = "Line_len" Then
  10. GetSet = Line_len
  11. ElseIf s = "Outline_Width" Then
  12. GetSet = Outline_Width
  13. End If
  14. End Function
  15. '// 获得剪贴板文本字符
  16. Public Function GetClipBoardString() As String
  17. On Error Resume Next
  18. Dim MyData As New DataObject
  19. GetClipBoardString = ""
  20. MyData.GetFromClipboard
  21. GetClipBoardString = MyData.GetText
  22. Set MyData = Nothing
  23. End Function
  24. '// 文本字符复制到剪贴板
  25. Public Function WriteClipBoard(ByVal s As String)
  26. On Error Resume Next
  27. ' VBA_WIN10(vba7) 使用PutInClipboard乱码解决办法
  28. #If VBA7 Then
  29. With CreateObject("Forms.TextBox.1")
  30. .MultiLine = True
  31. .text = s
  32. .SelStart = 0
  33. .SelLength = .TextLength
  34. .Copy
  35. End With
  36. #Else
  37. Dim MyData As New DataObject
  38. MyData.SetText s
  39. MyData.PutInClipboard
  40. #End If
  41. End Function
  42. '// 获得数组元素个数
  43. Public Function arrlen(src As Variant) As Integer
  44. On Error Resume Next '空意味着 0 长度
  45. arrlen = (UBound(src) - LBound(src))
  46. End Function
  47. '// 对数组进行排序[单维]
  48. Public Function ArraySort(src As Variant) As Variant
  49. Dim out As Long, i As Long, tmp As Variant
  50. For out = LBound(src) To UBound(src) - 1
  51. For i = out + 1 To UBound(src)
  52. If src(out) > src(i) Then
  53. tmp = src(i): src(i) = src(out): src(out) = tmp
  54. End If
  55. Next i
  56. Next out
  57. ArraySort = src
  58. End Function
  59. '// 测试数组排序
  60. Private test_ArraySort()
  61. Dim arr As Variant, i As Integer
  62. arr = Array(5, 4, 3, 2, 1, 9, 999, 33)
  63. For i = 0 To arrlen(arr) - 1
  64. Debug.Print arr(i);
  65. Next i
  66. Debug.Print arrlen(arr)
  67. ArraySort arr
  68. For i = 0 To arrlen(arr) - 1
  69. Debug.Print arr(i);
  70. Next i
  71. End Sub
  72. Function FindAllShapes() As ShapeRange
  73. Dim s As Shape
  74. Dim srPowerClipped As New ShapeRange
  75. Dim sr As ShapeRange, srAll As New ShapeRange
  76. If ActiveSelection.Shapes.Count > 0 Then
  77. Set sr = ActiveSelection.Shapes.FindShapes()
  78. Else
  79. Set sr = ActivePage.Shapes.FindShapes()
  80. End If
  81. Do
  82. For Each s In sr.Shapes.FindShapes(Query:="[email protected]")
  83. srPowerClipped.AddRange s.PowerClip.Shapes.FindShapes()
  84. Next s
  85. srAll.AddRange sr
  86. sr.RemoveAll
  87. sr.AddRange srPowerClipped
  88. srPowerClipped.RemoveAll
  89. Loop Until sr.Count = 0
  90. Set FindAllShapes = srAll
  91. End Function