- 精华
- 活跃值
-
- 积分
- 4375
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:485 天 连续签到:3 天
|
楼主 |
发表于 2025-1-12 16:32:13
|
显示全部楼层
Public Sub 批量外框()
ActiveDocument.BeginCommandGroup
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim X As Double, Y As Double, w As Double, h As Double
Dim s1 As Shape
Dim s2 As Shape
Dim pyl As Double
pyl = 5 ' 设置偏移量为5mm
If ActiveSelection.Shapes.Count <> 5 Then
For Each s2 In ActiveSelection.Shapes
s2.GetBoundingBox X, Y, w, h
Set s1 = ActiveLayer.CreateRectangle(X - pyl, Y - pyl, X + w + pyl, Y + h + pyl)
s1.Fill.ApplyNoFill ' 保持内部填充为无填充
' 设置外框形状的轮廓颜色为白色,以下是具体的设置颜色相关语句(根据不同软件环境可能需调整)
s1.Outline.SetColor CMYK(0, 0, 0, 0) ' 使用CMYK值设置颜色,这里白色对应CMYK(0, 0, 0, 0)
s1.Outline.Width = 1 ' 可以根据实际需求设置外框宽度,这里设为1mm,可调整
s2.AddToSelection
ActiveSelection.Group
Next s2
End If
ActiveDocument.EndCommandGroup ' 记得添加结束命令组语句,保持操作逻辑完整性
End Sub
ActiveDocument.EndCommandGroup
On Error GoTo ErrorHandler
Dim d As Document
Set d = ActiveDocument
Dim Sh As Shape, shs As Shapes
Dim Color As String
Set shs = ActiveSelection.Shapes
dpi = 300
Color = cdrRGBColorImage
'// 导出图片精度设置,设置颜色模式
Dim opt As New StructExportOptions
With opt
.ResolutionX = dpi
.ResolutionY = dpi
.ImageType = Color
.Transparent = True
End With
Dim Path$: Path = CorelScriptTools.GetFolder(d.FilePath)
'// 批处理导出图片
Dim i As Double
i = 1
For Each Sh In shs
ActiveDocument.ClearSelection
Sh.CreateSelection
' 导出图片PNG格式
f = Path & "\" & "p-" & i & ".png"
d.Export f, cdrPNG, cdrSelection, opt
i = i + 1
Next Sh
Beep
ErrorHandler:
End Sub
有哪个大神帮我 PNG格式改成 JPG的,或者在第一段代码添加的边框加个白底色也可以,默认路径设置导出在桌面文件夹 |
|