Tools.bas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. Attribute VB_Name = "Tools"
  2. Public Function 分分合合()
  3. 拼版裁切线.arrange
  4. CQL查找相同.CQLline_CM100
  5. 拼版裁切线.Cut_lines
  6. ' 记忆选择范围
  7. Dim X As Double, Y As Double, w As Double, h As Double
  8. ActiveSelectionRange.GetBoundingBox X, Y, w, h
  9. Set s = ActivePage.SelectShapesFromRectangle(X, Y, w, h, True)
  10. 自动中线色阶条.Auto_ColorMark
  11. End Function
  12. Public Function 傻瓜火车排列(space_width As Double)
  13. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  14. ActiveDocument.Unit = cdrMillimeter
  15. Dim ssr As ShapeRange, s As Shape
  16. Dim cnt As Integer
  17. Set ssr = ActiveSelectionRange
  18. cnt = 1
  19. #If VBA7 Then
  20. ' ssr.sort " @shape1.top>@shape2.top"
  21. ssr.Sort " @shape1.left<@shape2.left"
  22. #Else
  23. ' X4 不支持 ShapeRange.sort
  24. #End If
  25. ActiveDocument.ReferencePoint = cdrTopLeft
  26. For Each s In ssr
  27. '' 底对齐 If cnt > 1 Then s.SetPosition ssr(cnt - 1).RightX, ssr(cnt - 1).BottomY
  28. '' 改成顶对齐 2022-08-10
  29. ActiveDocument.ReferencePoint = cdrTopLeft + cdrBottomTop
  30. If cnt > 1 Then s.SetPosition ssr(cnt - 1).RightX + space_width, ssr(cnt - 1).TopY
  31. cnt = cnt + 1
  32. Next s
  33. ActiveDocument.EndCommandGroup
  34. Application.Optimization = False
  35. ActiveWindow.Refresh: Application.Refresh
  36. End Function
  37. Public Function 傻瓜阶梯排列(space_width As Double)
  38. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  39. Dim ssr As ShapeRange, s As Shape
  40. Dim cnt As Integer
  41. Set ssr = ActiveSelectionRange
  42. cnt = 1
  43. #If VBA7 Then
  44. ssr.Sort " @shape1.top>@shape2.top"
  45. ' ssr.sort " @shape1.left<@shape2.left"
  46. #Else
  47. ' X4 不支持 ShapeRange.sort
  48. #End If
  49. ActiveDocument.ReferencePoint = cdrTopLeft
  50. For Each s In ssr
  51. If cnt > 1 Then s.SetPosition ssr(cnt - 1).LeftX, ssr(cnt - 1).BottomY - space_width
  52. cnt = cnt + 1
  53. Next s
  54. ActiveDocument.EndCommandGroup
  55. Application.Optimization = False
  56. ActiveWindow.Refresh: Application.Refresh
  57. End Function
  58. '// 文本转曲线
  59. Public Function TextShape_ConvertToCurves()
  60. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  61. Dim s As Shape, cnt As Long
  62. For Each s In API.FindAllShapes.Shapes.FindShapes(, cdrTextShape)
  63. s.ConvertToCurves
  64. cnt = cnt + 1
  65. Next s
  66. MsgBox "转曲物件统计: " & cnt, , "文本转曲线"
  67. ActiveDocument.EndCommandGroup
  68. Application.Optimization = False
  69. ActiveWindow.Refresh: Application.Refresh
  70. End Function
  71. '' 复制物件
  72. Public Function copy_shape()
  73. Dim OrigSelection As ShapeRange
  74. Set OrigSelection = ActiveSelectionRange
  75. OrigSelection.Copy
  76. End Function
  77. '' 旋转物件角度
  78. Public Function Rotate_Shapes(n As Double)
  79. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  80. ActiveDocument.Unit = cdrMillimeter
  81. Dim sh As Shape, shs As Shapes
  82. Set shs = ActiveSelection.Shapes
  83. Dim s As String, size As String
  84. For Each sh In shs
  85. sh.Rotate n
  86. Next sh
  87. ActiveDocument.EndCommandGroup
  88. Application.Optimization = False
  89. ActiveWindow.Refresh: Application.Refresh
  90. End Function
  91. '' 得到物件尺寸
  92. Public Function get_shape_size(ByRef sx As Double, ByRef sy As Double)
  93. ActiveDocument.Unit = cdrMillimeter
  94. Dim sh As ShapeRange
  95. Set sh = ActiveSelectionRange
  96. sx = sh.SizeWidth
  97. sy = sh.SizeHeight
  98. sx = Int(sx * 100 + 0.5) / 100
  99. sy = Int(sy * 100 + 0.5) / 100
  100. End Function
  101. '' 批量设置物件尺寸
  102. Public Function Set_Shapes_size(ByRef sx As Double, ByRef sy As Double)
  103. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  104. ActiveDocument.Unit = cdrMillimeter
  105. ActiveDocument.ReferencePoint = cdrCenter
  106. Dim sh As Shape, shs As Shapes
  107. Set shs = ActiveSelection.Shapes
  108. Dim s As String, size As String
  109. For Each sh In shs
  110. sh.SizeWidth = sx
  111. sh.SizeHeight = sy
  112. Next sh
  113. ActiveDocument.EndCommandGroup
  114. Application.Optimization = False
  115. ActiveWindow.Refresh: Application.Refresh
  116. End Function
  117. Public Function 尺寸取整()
  118. If 0 = ActiveSelectionRange.Count Then Exit Function
  119. ActiveDocument.Unit = cdrMillimeter
  120. Dim sh As Shape, shs As Shapes
  121. Set shs = ActiveSelection.Shapes
  122. Dim s As String, size As String
  123. For Each sh In shs
  124. size = Int(sh.SizeWidth + 0.5) & "x" & Int(sh.SizeHeight + 0.5) & "mm"
  125. sh.SetSize Int(sh.SizeWidth + 0.5), Int(sh.SizeHeight + 0.5)
  126. s = s & size & vbNewLine
  127. Next sh
  128. MsgBox "物件尺寸信息到剪贴板" & vbNewLine & s & vbNewLine
  129. API.WriteClipBoard s
  130. End Function
  131. Public Function 居中页面()
  132. If 0 = ActiveSelectionRange.Count Then Exit Function
  133. ' 实践应用: 选择物件群组,页面设置物件大小,物件页面居中
  134. ActiveDocument.Unit = cdrMillimeter
  135. Dim OrigSelection As ShapeRange, sh As Shape
  136. Set OrigSelection = ActiveSelectionRange
  137. Set sh = OrigSelection.Group
  138. ActivePage.SetSize Int(sh.SizeWidth + 0.9), Int(sh.SizeHeight + 0.9)
  139. #If VBA7 Then
  140. ActiveDocument.ClearSelection
  141. sh.AddToSelection
  142. ActiveSelection.AlignAndDistribute 3, 3, 2, 0, False, 2
  143. #Else
  144. sh.AlignToPageCenter cdrAlignHCenter + cdrAlignVCenter
  145. #End If
  146. End Function
  147. '''/// 使用Python脚本 整理尺寸 提取条码数字 建立二维码 位图转文本 ///'''
  148. Public Function Python_Organize_Size()
  149. mypy = Path & "GMS\262235.xyz\Organize_Size.py"
  150. cmd_line = "pythonw " & Chr(34) & mypy & Chr(34)
  151. Shell cmd_line
  152. End Function
  153. Public Function Python_Get_Barcode_Number()
  154. mypy = Path & "GMS\262235.xyz\Get_Barcode_Number.py"
  155. cmd_line = "pythonw " & Chr(34) & mypy & Chr(34)
  156. Shell cmd_line
  157. End Function
  158. Public Function Python_BITMAP()
  159. mypy = Path & "GMS\262235.xyz\BITMAP.py"
  160. cmd_line = "pythonw " & Chr(34) & mypy & Chr(34)
  161. Shell cmd_line
  162. End Function
  163. Public Function Python_Make_QRCode()
  164. mypy = Path & "GMS\262235.xyz\Make_QRCode.py.py"
  165. cmd_line = "pythonw " & Chr(34) & mypy & Chr(34)
  166. Shell cmd_line
  167. End Function
  168. '' QRCode二维码制作
  169. Public Function QRCode_replace()
  170. On Error GoTo ErrorHandler
  171. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  172. Dim image_path As String
  173. image_path = API.GetClipBoardString
  174. ActiveDocument.ReferencePoint = cdrCenter
  175. Dim sh As Shape, shs As Shapes, cs As Shape
  176. Dim X As Double, Y As Double
  177. Set shs = ActiveSelection.Shapes
  178. cnt = 0
  179. For Each sh In shs
  180. If cnt = 0 Then
  181. ActiveDocument.ClearSelection
  182. ActiveLayer.Import image_path
  183. Set sc = ActiveSelection
  184. cnt = 1
  185. Else
  186. sc.Duplicate 0, 0
  187. End If
  188. sh.GetPosition X, Y
  189. sc.SetPosition X, Y
  190. sh.GetSize X, Y
  191. sc.SetSize X, Y
  192. sh.Delete
  193. Next sh
  194. '// 代码操作结束恢复窗口刷新
  195. ActiveDocument.EndCommandGroup
  196. Application.Optimization = False
  197. ActiveWindow.Refresh: Application.Refresh
  198. Exit Function
  199. ErrorHandler:
  200. Application.Optimization = False
  201. On Error Resume Next
  202. End Function
  203. '' QRCode二维码转矢量图
  204. Public Function QRCode_to_Vector()
  205. On Error GoTo ErrorHandler
  206. Set sr = ActiveSelectionRange
  207. With sr(1).Bitmap.Trace(cdrTraceHighQualityImage)
  208. .TraceType = cdrTraceHighQualityImage
  209. .Smoothing = 50 '数值小则平滑,数值大则细节多
  210. .RemoveBackground = False
  211. .DeleteOriginalObject = True
  212. .Finish
  213. End With
  214. Exit Function
  215. ErrorHandler:
  216. On Error Resume Next
  217. End Function
  218. '''//// 选择多物件,组合然后拆分线段,为角线爬虫准备 ////'''
  219. Public Function Split_Segment()
  220. On Error GoTo ErrorHandler
  221. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  222. Dim ssr As ShapeRange
  223. Set ssr = ActiveSelectionRange
  224. Dim s As Shape
  225. Dim nr As NodeRange
  226. Dim nd As Node
  227. Set s = ssr.UngroupAllEx.Combine
  228. Set nr = s.Curve.Nodes.All
  229. nr.BreakApart
  230. s.BreakApartEx
  231. ' For Each nd In nr
  232. ' nd.BreakApart
  233. ' Next nd
  234. ActiveDocument.EndCommandGroup
  235. Application.Optimization = False
  236. ActiveWindow.Refresh: Application.Refresh
  237. Exit Function
  238. ErrorHandler:
  239. Application.Optimization = False
  240. On Error Resume Next
  241. End Function
  242. '''//// 标记画框 支持容差 ////'''
  243. Public Function Mark_CreateRectangle(expand As Boolean)
  244. On Error GoTo ErrorHandler
  245. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  246. ActiveDocument.Unit = cdrMillimeter
  247. ActiveDocument.ReferencePoint = cdrBottomLeft
  248. Dim ssr As ShapeRange
  249. Set ssr = ActiveSelectionRange
  250. Dim sh As Shape
  251. Dim tr As Double
  252. tr = 0
  253. If GlobalUserData.Exists("Tolerance", 1) Then
  254. tr = Val(GlobalUserData("Tolerance", 1))
  255. End If
  256. For Each sh In ssr
  257. If expand = False Then
  258. mark_shape sh
  259. Else
  260. mark_shape_expand sh, tr
  261. End If
  262. Next sh
  263. ActiveDocument.EndCommandGroup
  264. Application.Optimization = False
  265. ActiveWindow.Refresh: Application.Refresh
  266. Exit Function
  267. ErrorHandler:
  268. Application.Optimization = False
  269. On Error Resume Next
  270. End Function
  271. Private Function mark_shape_expand(sh As Shape, tr As Double)
  272. Dim s As Shape
  273. Dim X As Double, Y As Double, w As Double, h As Double, r As Double
  274. sh.GetBoundingBox X, Y, w, h
  275. X = X - tr: Y = Y - tr: w = w + 2 * tr: h = h + 2 * tr
  276. r = Max(w, h) / Min(w, h) / 30 * Math.Sqr(w * h)
  277. If w < h Then
  278. Set s = ActiveLayer.CreateRectangle2(X - r, Y, w + 2 * r, h)
  279. Else
  280. Set s = ActiveLayer.CreateRectangle2(X, Y - r, w, h + 2 * r)
  281. End If
  282. s.Outline.SetProperties Color:=CreateRGBColor(0, 255, 0)
  283. End Function
  284. Private Function mark_shape(sh As Shape)
  285. Dim s As Shape
  286. Dim X As Double, Y As Double, w As Double, h As Double
  287. sh.GetBoundingBox X, Y, w, h
  288. Set s = ActiveLayer.CreateRectangle2(X, Y, w, h)
  289. s.Outline.SetProperties Color:=CreateRGBColor(0, 255, 0)
  290. End Function
  291. Private Function Max(ByVal a, ByVal b)
  292. If a < b Then
  293. a = b
  294. End If
  295. Max = a
  296. End Function
  297. Private Function Min(ByVal a, ByVal b)
  298. If a > b Then
  299. a = b
  300. End If
  301. Min = a
  302. End Function
  303. '''//// 批量组合合并 ////'''
  304. Public Function Batch_Combine()
  305. On Error GoTo ErrorHandler
  306. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  307. Dim ssr As ShapeRange
  308. Set ssr = ActiveSelectionRange
  309. Dim sh As Shape
  310. For Each sh In ssr
  311. sh.UngroupAllEx.Combine
  312. Next sh
  313. ActiveDocument.EndCommandGroup
  314. Application.Optimization = False
  315. ActiveWindow.Refresh: Application.Refresh
  316. Exit Function
  317. ErrorHandler:
  318. Application.Optimization = False
  319. On Error Resume Next
  320. End Function
  321. '''//// 一键拆开多行组合的文字字符 ////''' ''' 本功能由群友半缘君赞助发行 '''
  322. Public Function Take_Apart_Character()
  323. On Error GoTo ErrorHandler
  324. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  325. ActiveDocument.Unit = cdrMillimeter
  326. ActiveDocument.ReferencePoint = cdrBottomLeft
  327. Dim ssr As ShapeRange
  328. Set ssr = ActiveSelectionRange
  329. Dim s1 As Shape, sh As Shape, s As Shape
  330. Dim tr As Double
  331. ' 记忆选择范围
  332. Dim X As Double, Y As Double, w As Double, h As Double
  333. ssr.GetBoundingBox X, Y, w, h
  334. Set s1 = ActiveLayer.CreateRectangle2(X, Y, w, h)
  335. ' 解散群组,先组合,再散开
  336. Set s = ssr.UngroupAllEx.Combine
  337. Set ssr = s.BreakApartEx
  338. ' 读取容差值
  339. tr = 0
  340. If GlobalUserData.Exists("Tolerance", 1) Then
  341. tr = Val(GlobalUserData("Tolerance", 1))
  342. End If
  343. ' 标记画框,选择标记框
  344. For Each sh In ssr
  345. mark_shape_expand sh, tr
  346. Next sh
  347. Set ssr = ActivePage.Shapes.FindShapes(Query:="@colors.find(RGB(0, 255, 0))")
  348. ActiveDocument.ClearSelection
  349. ssr.AddToSelection
  350. ' 调用 智能群组 后删除标记画框
  351. 智能群组和查找.智能群组
  352. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  353. ssr.Delete
  354. Set sh = ActivePage.SelectShapesFromRectangle(s1.LeftX, s1.TopY, s1.RightX, s1.BottomY, False)
  355. ' sh.Shapes.All.Group
  356. s1.Delete
  357. ' 通过s1矩形范围选择群组后合并组合
  358. For Each s In sh.Shapes
  359. s.UngroupAllEx.Combine
  360. Next s
  361. ActiveDocument.EndCommandGroup
  362. Application.Optimization = False
  363. ActiveWindow.Refresh: Application.Refresh
  364. Exit Function
  365. ErrorHandler:
  366. Application.Optimization = False
  367. On Error Resume Next
  368. End Function
  369. '''//// 简单一刀切 识别群组 ////''' ''' 本功能由群友宏瑞广告赞助发行 '''
  370. Public Function Single_Line()
  371. If 0 = ActiveSelectionRange.Count Then Exit Function
  372. On Error GoTo ErrorHandler
  373. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  374. ActiveDocument.Unit = cdrMillimeter
  375. Dim cm(2) As Color
  376. Set cm(0) = CreateRGBColor(0, 255, 0) ' RGB 绿
  377. Set cm(1) = CreateRGBColor(255, 0, 0) ' RGB 红
  378. Dim ssr As ShapeRange
  379. Dim SrNew As New ShapeRange
  380. Dim s As Shape, s1 As Shape, line As Shape, line2 As Shape
  381. Dim cnt As Integer
  382. cnt = 1
  383. If 1 = ActiveSelectionRange.Count Then
  384. Set ssr = ActiveSelectionRange(1).UngroupAllEx
  385. Else
  386. Set ssr = ActiveSelectionRange
  387. End If
  388. ' 记忆选择范围
  389. Dim X As Double, Y As Double, w As Double, h As Double
  390. ssr.GetBoundingBox X, Y, w, h
  391. Set s1 = ActiveLayer.CreateRectangle2(X, Y, w, h)
  392. s1.Outline.SetProperties Color:=cm(0)
  393. SrNew.Add s1
  394. #If VBA7 Then
  395. ' ssr.sort " @shape1.top>@shape2.top"
  396. ssr.Sort " @shape1.left<@shape2.left"
  397. #Else
  398. ' X4 不支持 ShapeRange.sort
  399. #End If
  400. ''' 相交 Set line2 = line.Intersect(s, True, True)
  401. ''' 判断相交 line.Curve.IntersectsWith(s.Curve)
  402. For Each s In ssr
  403. If cnt > 1 Then
  404. s.ConvertToCurves
  405. Set line = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY, s.LeftX, s.TopY - s.SizeHeight)
  406. line.Outline.SetProperties Color:=cm(1)
  407. SrNew.Add line
  408. End If
  409. cnt = cnt + 1
  410. Next s
  411. SrNew.Group
  412. ActiveDocument.EndCommandGroup
  413. Application.Optimization = False
  414. ActiveWindow.Refresh: Application.Refresh
  415. Exit Function
  416. ErrorHandler:
  417. Application.Optimization = False
  418. On Error Resume Next
  419. End Function
  420. Public Function Single_Line_Vertical()
  421. If 0 = ActiveSelectionRange.Count Then Exit Function
  422. On Error GoTo ErrorHandler
  423. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  424. ActiveDocument.Unit = cdrMillimeter
  425. Dim cm(2) As Color
  426. Set cm(0) = CreateRGBColor(0, 255, 0) ' RGB 绿
  427. Set cm(1) = CreateRGBColor(255, 0, 0) ' RGB 红
  428. Dim ssr As ShapeRange
  429. Dim SrNew As New ShapeRange
  430. Dim s As Shape, s1 As Shape, line As Shape, line2 As Shape
  431. Dim cnt As Integer
  432. cnt = 1
  433. If 1 = ActiveSelectionRange.Count Then
  434. Set ssr = ActiveSelectionRange(1).UngroupAllEx
  435. Else
  436. Set ssr = ActiveSelectionRange
  437. End If
  438. ' 记忆选择范围
  439. Dim X As Double, Y As Double, w As Double, h As Double
  440. ssr.GetBoundingBox X, Y, w, h
  441. Set s1 = ActiveLayer.CreateRectangle2(X, Y, w, h)
  442. s1.Outline.SetProperties Color:=cm(0)
  443. SrNew.Add s1
  444. #If VBA7 Then
  445. ssr.Sort " @shape1.top>@shape2.top"
  446. #Else
  447. ' X4 不支持 ShapeRange.sort
  448. #End If
  449. For Each s In ssr
  450. If cnt > 1 Then
  451. s.ConvertToCurves
  452. Set line = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY, s.RightX, s.TopY)
  453. line.Outline.SetProperties Color:=cm(1)
  454. SrNew.Add line
  455. End If
  456. cnt = cnt + 1
  457. Next s
  458. SrNew.Group
  459. ActiveDocument.EndCommandGroup
  460. Application.Optimization = False
  461. ActiveWindow.Refresh: Application.Refresh
  462. Exit Function
  463. ErrorHandler:
  464. Application.Optimization = False
  465. On Error Resume Next
  466. End Function
  467. Public Function Single_Line_LastNode()
  468. If 0 = ActiveSelectionRange.Count Then Exit Function
  469. ' On Error GoTo ErrorHandler
  470. ' ActiveDocument.BeginCommandGroup: Application.Optimization = True
  471. ActiveDocument.Unit = cdrMillimeter
  472. Dim cm(2) As Color
  473. Set cm(0) = CreateRGBColor(0, 255, 0) ' RGB 绿
  474. Set cm(1) = CreateRGBColor(255, 0, 0) ' RGB 红
  475. Dim ssr As ShapeRange
  476. Dim SrNew As New ShapeRange
  477. Dim s As Shape, s1 As Shape, line As Shape, line2 As Shape
  478. Dim cnt As Integer
  479. cnt = 1
  480. If 1 = ActiveSelectionRange.Count Then
  481. Set ssr = ActiveSelectionRange(1).UngroupAllEx
  482. Else
  483. Set ssr = ActiveSelectionRange
  484. End If
  485. ' 记忆选择范围
  486. Dim X As Double, Y As Double, w As Double, h As Double
  487. ssr.GetBoundingBox X, Y, w, h
  488. Set s1 = ActiveLayer.CreateRectangle2(X, Y, w, h)
  489. s1.Outline.SetProperties Color:=cm(0)
  490. SrNew.Add s1
  491. #If VBA7 Then
  492. ssr.Sort " @shape1.left<@shape2.left"
  493. #Else
  494. ' X4 不支持 ShapeRange.sort
  495. #End If
  496. Dim nr As NodeRange
  497. For Each s In ssr
  498. If cnt > 1 Then
  499. Set nr = s.DisplayCurve.Nodes.All
  500. Set line = ActiveLayer.CreateLineSegment(nr.FirstNode.PositionX, nr.FirstNode.PositionY, nr.LastNode.PositionX, nr.LastNode.PositionY)
  501. line.Outline.SetProperties Color:=cm(1)
  502. SrNew.Add line
  503. End If
  504. cnt = cnt + 1
  505. Next s
  506. SrNew.Group
  507. ActiveDocument.EndCommandGroup
  508. Application.Optimization = False
  509. ActiveWindow.Refresh: Application.Refresh
  510. Exit Function
  511. ErrorHandler:
  512. Application.Optimization = False
  513. On Error Resume Next
  514. End Function
  515. '''//// 选择范围画框 ////'''
  516. Public Function Mark_Range_Box()
  517. If 0 = ActiveSelectionRange.Count Then Exit Function
  518. ActiveDocument.Unit = cdrMillimeter
  519. Dim s1 As Shape, ssr As ShapeRange
  520. Set ssr = ActiveSelectionRange
  521. Dim X As Double, Y As Double, w As Double, h As Double
  522. ssr.GetBoundingBox X, Y, w, h
  523. Set s1 = ActiveLayer.CreateRectangle2(X, Y, w, h)
  524. s1.Outline.SetProperties Color:=CreateRGBColor(0, 255, 0) ' RGB 绿
  525. End Function