{"id":1028,"date":"2022-04-28T05:28:00","date_gmt":"2022-04-28T05:28:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=1028"},"modified":"2022-04-28T05:28:00","modified_gmt":"2022-04-28T05:28:00","slug":"1028","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2022\/04\/28\/1028\/","title":{"rendered":"CorelDRAW VBA \u7b80\u5355\u4ee3\u7801\u5b9e\u73b0\u5b9e\u7528\u7528\u5de5\u5177-\u50bb\u74dc\u706b\u8f66\u6392\u5217"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2022\/04\/2235738865.webp\" alt=\"1569150005.webp\" title=\"1569150005.webp\"><\/p>\n<h2>CorelDRAW \u597d\u50cf\u6ca1\u6709\u591a\u4e2a\u7269\u4ef6\u7684\u5bf9\u51c6\u6392\u5217\uff0c\u5de5\u4f5c\u4e2d\u53c8\u7ecf\u5e38\u7528\u5230\uff0c\u6240\u4ee5\u5199\u4e86\u4e2a\u7b80\u5355\u4ee3\u7801<\/h2>\n<pre><code>Sub \u50bb\u74dc\u706b\u8f66\u6392\u5217()\n  ActiveDocument.ReferencePoint = cdrBottomLeft  '\/\/ \u8bbe\u7f6e\u5bf9\u51c6\u57fa\u51c6 \u5de6\u4e0b\n  Dim ssr As ShapeRange, s As Shape     '\/\/ \u5b9a\u4e49\u9009\u62e9\u7269\u4ef6\u6570\u7ec4 ssr\uff0c \u548c\u904d\u5386\u7269\u4ef6 s\n  Dim cnt As Integer                    '\/\/ \u5b9a\u4e49\u7269\u4ef6\u4e2a\u6570\u8ba1\u6570\u5668\n  Set ssr = ActiveSelectionRange\n  cnt = 1\n\n  For Each s In ssr\n    If cnt &gt; 1 Then s.SetPosition ssr(cnt - 1).LeftX + ssr(cnt - 1).SizeWidth, ssr(cnt - 1).BottomY\n    cnt = cnt + 1\n  Next s\n\nEnd Sub<\/code><\/pre>\n<h2>\u4ee3\u7801\u8fd8\u53ef\u4ee5\u7ee7\u7eed\u4f18\u5316\u548c\u6539\u5199\u6210\u4e24\u79cd\u65b9\u5411\u6392\u5217: \u706b\u8f66\u6392\u5217(\u884c) \u548c \u9636\u68af\u6392\u5217(\u7ad6)<\/h2>\n<pre><code>Sub \u50bb\u74dc\u706b\u8f66\u6392\u5217()\n  Dim ssr As ShapeRange, s As Shape\n  Dim cnt As Integer\n  Set ssr = ActiveSelectionRange\n  cnt = 1\n\n  ActiveDocument.ReferencePoint = cdrBottomLeft\n  For Each s In ssr\n    If cnt &gt; 1 Then s.SetPosition ssr(cnt - 1).RightX, ssr(cnt - 1).BottomY\n    cnt = cnt + 1\n  Next s\n\nEnd Sub\n\nSub \u50bb\u74dc\u9636\u68af\u6392\u5217()\n  Dim ssr As ShapeRange, s As Shape\n  Dim cnt As Integer\n  Set ssr = ActiveSelectionRange\n  cnt = 1\n\n  ActiveDocument.ReferencePoint = cdrTopLeft\n  For Each s In ssr\n    If cnt &gt; 1 Then s.SetPosition ssr(cnt - 1).LeftX, ssr(cnt - 1).BottomY\n    cnt = cnt + 1\n  Next s\n\nEnd Sub\n<\/code><\/pre>\n<h2>CorelDRAW X5 \u4ee5\u4e0a\u652f\u6301 <code>ShapeRange<\/code> \u7269\u4ef6 \u901a\u8fc7CQL\u67e5\u8be2\u5c3a\u5bf8\u548c\u5750\u6807\uff0c\u4f7f\u7528 <code>Sort<\/code> \u65b9\u6cd5\u6392\u5e8f<\/h2>\n<pre><code>Public Function \u50bb\u74dc\u706b\u8f66\u6392\u5217()\n  ActiveDocument.BeginCommandGroup:  Application.Optimization = True\n  Dim ssr As ShapeRange, s As Shape\n  Dim cnt As Integer\n  Set ssr = ActiveSelectionRange\n  cnt = 1\n\n#If VBA7 Then\n'  ssr.sort \" @shape1.top&gt;@shape2.top\"\n  ssr.Sort \" @shape1.left&lt;@shape2.left\"\n#Else\n' X4 \u4e0d\u652f\u6301 ShapeRange.sort\n#End If\n\n  ActiveDocument.ReferencePoint = cdrBottomLeft\n  For Each s In ssr\n    If cnt &gt; 1 Then s.SetPosition ssr(cnt - 1).RightX, ssr(cnt - 1).BottomY\n    cnt = cnt + 1\n  Next s\n\n  ActiveDocument.EndCommandGroup\n  Application.Optimization = False\n  ActiveWindow.Refresh:    Application.Refresh\nEnd Function\n\n\nPublic Function \u50bb\u74dc\u9636\u68af\u6392\u5217()\n  ActiveDocument.BeginCommandGroup:  Application.Optimization = True\n  Dim ssr As ShapeRange, s As Shape\n  Dim cnt As Integer\n  Set ssr = ActiveSelectionRange\n  cnt = 1\n\n#If VBA7 Then\n  ssr.Sort \" @shape1.top&gt;@shape2.top\"\n'  ssr.sort \" @shape1.left&lt;@shape2.left\"\n#Else\n' X4 \u4e0d\u652f\u6301 ShapeRange.sort\n#End If\n\n  ActiveDocument.ReferencePoint = cdrTopLeft\n  For Each s In ssr\n    If cnt &gt; 1 Then s.SetPosition ssr(cnt - 1).LeftX, ssr(cnt - 1).BottomY\n    cnt = cnt + 1\n  Next s\n\n  ActiveDocument.EndCommandGroup\n  Application.Optimization = False\n  ActiveWindow.Refresh:    Application.Refresh\nEnd Function<\/code><\/pre>\n<h2>\u4e2a\u4eba\u4e3b\u8981\u7528CorelDRAW X4 \u505a\u4e9b\u8f85\u52a9\u624b\u5de5\u62fc\u7248\uff0c\u627e\u4e0d\u5230\u597d\u7684\u65b9\u6cd5\u6392\u5e8f<\/h2>\n<pre><code>'\/\/ \u83b7\u5f97\u6570\u7ec4\u5143\u7d20\u4e2a\u6570\nPublic Function arrlen(src As Variant) As Integer\n  On Error Resume Next '\u7a7a\u610f\u5473\u7740 0 \u957f\u5ea6\n  arrlen = (UBound(src) - LBound(src))\nEnd Function\n\n'\/\/ \u5bf9\u6570\u7ec4\u8fdb\u884c\u6392\u5e8f[\u5355\u7ef4]\nPublic Function ArraySort(src As Variant) As Variant\n  Dim out As Long, i As Long, tmp As Variant\n  For out = LBound(src) To UBound(src) - 1\n    For i = out + 1 To UBound(src)\n      If src(out) &gt; src(i) Then\n        tmp = src(i): src(i) = src(out): src(out) = tmp\n      End If\n    Next i\n  Next out\n\n  ArraySort = src\nEnd Function\n\n'\/\/ \u6d4b\u8bd5\u6570\u7ec4\u6392\u5e8f\nPrivate test_ArraySort()\n  Dim arr As Variant, i As Integer\n  arr = Array(5, 4, 3, 2, 1, 9, 999, 33)\n  For i = 0 To arrlen(arr) - 1\n    Debug.Print arr(i);\n  Next i\n  Debug.Print arrlen(arr)\n  ArraySort arr\n  For i = 0 To arrlen(arr) - 1\n    Debug.Print arr(i);\n  Next i\nEnd Sub<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CorelDRAW \u597d\u50cf\u6ca1\u6709\u591a\u4e2a\u7269\u4ef6\u7684\u5bf9\u51c6\u6392\u5217\uff0c\u5de5\u4f5c\u4e2d\u53c8\u7ecf\u5e38\u7528\u5230\uff0c\u6240\u4ee5\u5199\u4e86\u4e2a\u7b80\u5355\u4ee3\u7801 Sub \u50bb\u74dc\u706b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12],"tags":[67],"class_list":["post-1028","post","type-post","status-publish","format-standard","hentry","category-soft","category-learn","tag-vba"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=1028"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1028\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}