{"id":995,"date":"2022-03-17T14:28:00","date_gmt":"2022-03-17T14:28:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=995"},"modified":"2022-03-17T14:28:00","modified_gmt":"2022-03-17T14:28:00","slug":"995","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2022\/03\/17\/995\/","title":{"rendered":"CorelDRAW VBA \u5efa\u7acb\u81ea\u5df1\u7684\u5de5\u5177-\u526a\u8d34\u677f\u5c3a\u5bf8\u5efa\u7acb\u77e9\u5f62"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2022\/03\/525753621.webp\" alt=\"295916658.webp\" title=\"295916658.webp\"><\/p>\n<h2>github \u6e90\u7801\u5206\u4eab <a href=\"https:\/\/github.com\/hongwenjun\/corelvba\">https:\/\/github.com\/hongwenjun\/corelvba<\/a><\/h2>\n<h2>\u529f\u80fd\u6f14\u793a<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2022\/03\/1759911447.gif\" alt=\"GIF.gif\" title=\"GIF.gif\"><\/p>\n<h2>\u5b8c\u5584\u5de5\u5177<\/h2>\n<pre><code>Sub start()\n    '\/\/ \u5efa\u7acb\u77e9\u5f62 Width  x Height \u5355\u4f4d mm\n    ' Rectangle 101, 151\n\n    ' setRectangle 200, 200\n\n    Dim Str, arr, n\n    Str = GetClipBoardString\n\n    ' \u66ff\u6362 mm x * \u6362\u884c\u4e3a\u7a7a\u683c\n    Str = VBA.Replace(Str, \"mm\", \" \")\n    Str = VBA.Replace(Str, \"x\", \" \")\n    Str = VBA.Replace(Str, \"*\", \" \")\n    Str = VBA.Replace(Str, Chr(10), \" \")\n\n    Do While InStr(Str, \"  \") '\u591a\u4e2a\u7a7a\u683c\u6362\u6210\u4e00\u4e2a\u7a7a\u683c\n        Str = VBA.Replace(Str, \"  \", \" \")\n    Loop\n\n    arr = Split(Str)\n\n    Dim x As Double\n    Dim y As Double\n    For n = LBound(arr) To UBound(arr) - 1 Step 2\n        ' MsgBox arr(n)\n        x = Val(arr(n))\n        y = Val(arr(n + 1))\n\n        If x &gt; 0 And y &gt; 0 Then\n            Rectangle x, y\n        End If\n\n    Next\n\nEnd Sub<\/code><\/pre>\n<h2>\u57fa\u672c\u7a0b\u5e8f<\/h2>\n<pre><code>Sub start()\n    Dim Str, arr, n\n    Str = GetClipBoardString\n    arr = Split(Str)\n    For n = LBound(arr) To UBound(arr)\n       MsgBox arr(n)\n    Next\nEnd Sub\n\nFunction Rectangle(Width As Double, Height As Double)\n\n    ActiveDocument.Unit = cdrMillimeter\n    Dim size As Shape\n    Dim d As Document\n    Dim s1 As Shape\n\n    '\/\/ \u5efa\u7acb\u77e9\u5f62 Width  x Height \u5355\u4f4d mm\n    Set s1 = ActiveLayer.CreateRectangle(0, 0, Width, Height)\n\n    '\/\/ \u586b\u5145\u989c\u8272\u65e0\uff0c\u8f6e\u5ed3\u989c\u8272 K100\uff0c\u7ebf\u6761\u7c97\u7ec60.3mm\n    s1.Fill.ApplyNoFill\n    s1.Outline.SetProperties 0.3, OutlineStyles(0), CreateCMYKColor(0, 100, 0, 0), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#\n\n    sw = s1.SizeWidth\n    sh = s1.SizeHeight\n\n    Text = \"\u5efa\u7acb\u77e9\u5f62:\" + Str(sw) + \" x\" + Str(sh) + \"mm\"\n    MsgBox Text\n\n    Text = Trim(Str(sw)) + \"x\" + Trim(Str(sh)) + \"mm\"\n    Set d = ActiveDocument\n    Set size = d.ActiveLayer.CreateArtisticText(0, 0, Text)\n    size.Fill.UniformColor.CMYKAssign 0, 100, 100, 0\n\nEnd Function\n\nFunction setRectangle(Width As Double, Height As Double)\n\n    Dim s1 As Shape\n    Set s1 = ActiveSelection\n    ActiveDocument.Unit = cdrMillimeter\n    '\/\/ \u7269\u4ef6\u4e2d\u5fc3\u57fa\u51c6, \u5148\u628a\u5bbd\u5ea6\u8bbe\u5b9a\u4e3a\n    ActiveDocument.ReferencePoint = cdrCenter\n    s1.SetSize Height, Height\n\n    '\/\/ \u7269\u4ef6\u65cb\u8f6c 30\u5ea6\uff0c\u8f6e\u5ed3\u7ebf1mm ,\u8f6e\u5ed3\u989c\u8272 M100Y100\n    s1.Rotate 30#\n    s1.Outline.SetProperties 1#\n    s1.Outline.SetProperties Color:=CreateCMYKColor(0, 100, 100, 0)\n\nEnd Function\n\nSub DoIt()\n    MsgBox GetClipBoardString\nEnd Sub\n\nPrivate Function GetClipBoardString() As String\n    On Error Resume Next\n    Dim MyData As New DataObject\n    GetClipBoardString = \"\"\n    MyData.GetFromClipboard\n    GetClipBoardString = MyData.GetText\n    Set MyData = Nothing\nEnd Function\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>github \u6e90\u7801\u5206\u4eab https:\/\/github.com\/hongwenjun\/corelvba [&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-995","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\/995","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=995"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/995\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}