123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- Attribute VB_Name = "剪贴板尺寸建立矩形"
- Type Coordinate
- x As Double
- Y As Double
- End Type
- Public O_O As Coordinate
- Sub start()
-
- O_O.x = 0: O_O.Y = 0
- Dim ost As ShapeRange
- Set ost = ActiveSelectionRange
- O_O.x = ost.LeftX
- O_O.Y = ost.BottomY - 50
-
- Dim Str, arr, n
- Str = API.GetClipBoardString
-
- Str = VBA.replace(Str, "m", " ")
- Str = VBA.replace(Str, "x", " ")
- Str = VBA.replace(Str, "X", " ")
- Str = VBA.replace(Str, "*", " ")
- Str = VBA.replace(Str, vbNewLine, " ")
- Do While InStr(Str, " ")
- Str = VBA.replace(Str, " ", " ")
- Loop
- arr = Split(Str)
-
- ActiveDocument.BeginCommandGroup
- Dim x As Double
- Dim Y As Double
- For n = LBound(arr) To UBound(arr) - 1 Step 2
-
- x = Val(arr(n))
- Y = Val(arr(n + 1))
-
- If x > 0 And Y > 0 Then
- Rectangle x, Y
- O_O.x = O_O.x + x + 30
- End If
- Next
- ActiveDocument.EndCommandGroup
- End Sub
- Private Function Rectangle(Width As Double, Height As Double)
- ActiveDocument.Unit = cdrMillimeter
- Dim size As Shape
- Dim d As Document
- Dim s1 As Shape
-
- Set s1 = ActiveLayer.CreateRectangle(O_O.x, O_O.Y, O_O.x + Width, O_O.Y - Height)
-
-
- s1.Fill.ApplyNoFill
- s1.Outline.SetProperties 0.3, OutlineStyles(0), CreateCMYKColor(0, 100, 0, 0), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#
-
- sw = s1.SizeWidth
- sh = s1.SizeHeight
- text = Trim(Str(sw)) + "x" + Trim(Str(sh)) + "mm"
- Set d = ActiveDocument
- Set size = d.ActiveLayer.CreateArtisticText(O_O.x + sw / 2 - 25, O_O.Y + 10, text, Font:="Tahoma")
- size.Fill.UniformColor.CMYKAssign 0, 100, 100, 0
- End Function
- Private Function setRectangle(Width As Double, Height As Double)
- Dim s1 As Shape
- Set s1 = ActiveSelection
- ActiveDocument.Unit = cdrMillimeter
-
- ActiveDocument.ReferencePoint = cdrCenter
- s1.SetSize Height, Height
-
- s1.Rotate 30#
- s1.Outline.SetProperties 1#
- s1.Outline.SetProperties Color:=CreateCMYKColor(0, 100, 100, 0)
- End Function
- Sub get_all_size()
- ActiveDocument.Unit = cdrMillimeter
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set F = fs.CreateTextFile("R:\size.txt", True)
- Dim sh As Shape, shs As Shapes
- Set shs = ActiveSelection.Shapes
- Dim s As String
- For Each sh In shs
- size = Trim(Str(Int(sh.SizeWidth + 0.5))) + "x" + Trim(Str(Int(sh.SizeHeight + 0.5))) + "mm"
- F.WriteLine (size)
- s = s + size + vbNewLine
- Next sh
- F.Close
- MsgBox "输出物件尺寸信息到文件" & "R:\size.txt" & vbNewLine & s
- API.WriteClipBoard s
- End Sub
|