123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- Attribute VB_Name = "Container"
- Public Function SetBoxName()
- API.BeginOpt "标记容器盒子"
-
- Dim box As ShapeRange, s As Shape
- Set box = ActiveSelectionRange
-
-
- For Each s In box
- s.Name = "Container"
- Next s
-
- API.EndOpt
- MsgBox "标记容器盒子" & vbNewLine & "名字: Container"
- End Function
- Public Sub Batch_ToPowerClip()
- API.BeginOpt "批量置入容器"
- Dim s As Shape, ssr As ShapeRange, box As ShapeRange
- Set ssr = Smart_Group(0.5)
-
- For Each s In ssr
- Image_ToPowerClip s
- Next s
- API.EndOpt
- End Sub
- Public Function Image_ToPowerClip(arg As Shape)
- Dim box As ShapeRange
- Dim ssr As New ShapeRange, rmsr As New ShapeRange
- Set ssr = arg.UngroupEx
-
- Set box = ssr.Shapes.FindShapes(Query:="@name ='Container'")
- ssr.RemoveRange box
-
- If box.Count = 0 Then Exit Function
-
- box.SetOutlineProperties Width:=0, Color:=Nothing
- ssr.AddToPowerClip box(1), 0
- box(1).Name = "powerclip_ok"
- End Function
- Public Sub OneKey_ToPowerClip()
- API.BeginOpt "图片OneKey置入容器"
- Dim s As Shape, ssr As ShapeRange, box As ShapeRange
-
-
- Set box = ActiveSelectionRange
- For Each s In box
- If s.Type <> cdrBitmapShape Then s.Name = "Container"
- Next s
-
- Set ssr = Smart_Group(0.5)
-
- Application.Optimization = True
- For Each s In ssr
- Image_ToPowerClip s
- Next s
- API.EndOpt
- End Sub
- Public Function Remove_OutsideBox()
- Dim s As Shape
- Dim ssr As ShapeRange, box As ShapeRange
- Dim rmsr As New ShapeRange
- Dim x As Double, Y As Double
-
- Set ssr = ActiveSelectionRange
-
- Set box = ssr.Shapes.FindShapes(Query:="@name ='Container'")
- ssr.RemoveRange box
-
- If box.Count = 0 Then Exit Function
-
- ActiveDocument.Unit = cdrMillimeter
- For Each s In ssr
- x = s.CenterX: Y = s.CenterY
- If box(1).IsOnShape(x, Y) = cdrOutsideShape Then rmsr.Add s
- Next s
- rmsr.Delete
- End Function
- Public Function Remove_OnMargin()
- Dim s As Shape
- Dim ssr As ShapeRange, box As ShapeRange
- Dim rmsr As New ShapeRange
- Dim x As Double, Y As Double
-
- Set ssr = ActiveSelectionRange
-
- Set box = ssr.Shapes.FindShapes(Query:="@name ='Container'")
- ssr.RemoveRange box
-
- If box.Count = 0 Then Exit Function
-
- ActiveDocument.Unit = cdrMillimeter
- For Each s In ssr
- x = s.CenterX: Y = s.CenterY
- If box(1).IsOnShape(x, Y) = cdrOnMarginOfShape Then rmsr.Add s
- Next s
- rmsr.Delete
- End Function
- Public Function Select_OutsideBox()
- Dim s As Shape
- Dim ssr As ShapeRange, box As ShapeRange
- Dim SelSr As New ShapeRange
- Dim x As Double, Y As Double, radius
-
- Set ssr = ActiveSelectionRange
-
- Set box = ssr.Shapes.FindShapes(Query:="@name ='Container'")
- ssr.RemoveRange box
-
- If box.Count = 0 Then Exit Function
-
- ActiveDocument.Unit = cdrMillimeter
- For Each s In ssr
- x = s.CenterX: Y = s.CenterY
- radius = s.SizeWidth / 2
- If box(1).IsOnShape(x, Y, radius) = cdrOutsideShape Then SelSr.Add s
- Next s
-
- ActiveDocument.ClearSelection
- SelSr.AddToSelection
- End Function
- Public Function Select_OnMargin()
- Dim s As Shape
- Dim ssr As ShapeRange, box As ShapeRange
- Dim SelSr As New ShapeRange
- Dim x As Double, Y As Double, radius
-
- Set ssr = ActiveSelectionRange
-
- Set box = ssr.Shapes.FindShapes(Query:="@name ='Container'")
- ssr.RemoveRange box
-
- If box.Count = 0 Then Exit Function
-
- ActiveDocument.Unit = cdrMillimeter
- For Each s In ssr
- x = s.CenterX: Y = s.CenterY
- radius = s.SizeWidth / 2
- If box(1).IsOnShape(x, Y, radius) = cdrOnMarginOfShape Then SelSr.Add s
- Next s
-
- ActiveDocument.ClearSelection
- SelSr.AddToSelection
- End Function
- Public Sub Batch_Center()
- Dim s As Shape, ssr As ShapeRange
- Set ssr = Smart_Group
- For Each s In ssr
- Ungroup_Center s
- Next s
- End Sub
- Private Function Ungroup_Center(os As Shape)
- Set grp = os.UngroupEx
- grp.Sort "@shape1.Width * @shape1.Height> @shape2.Width * @shape2.Height"
- cx = grp(1).CenterX
- cy = grp(1).CenterY
- For Each s In grp
- s.CenterX = cx
- s.CenterY = cy
- Next s
- End Function
|