Macros 用于为页面上的所有形状提供公共边框的宏
我正在使用CorelDraw X7。我有一个包含许多形状的页面,我希望构造一个宏来更改它, 因此所有形状的边界矩形(包含所有形状的最小矩形) 将具有给定大小的公共边框。 我可以找到边框的大小,并尝试使用ActiveSelection.AlignAndDistribute子菜单 来移动形状,但是这个子程序有很多参数,我不理解(“帮助”对我没有帮助) 我的想法是:Macros 用于为页面上的所有形状提供公共边框的宏,macros,coreldraw,Macros,Coreldraw,我正在使用CorelDraw X7。我有一个包含许多形状的页面,我希望构造一个宏来更改它, 因此所有形状的边界矩形(包含所有形状的最小矩形) 将具有给定大小的公共边框。 我可以找到边框的大小,并尝试使用ActiveSelection.AlignAndDistribute子菜单 来移动形状,但是这个子程序有很多参数,我不理解(“帮助”对我没有帮助) 我的想法是: 指定边框,例如pgBorder 获取边框的宽度和高度,例如shpsWidth和shpsHeight 移动形状,使新边界矩形的左下角具有坐
Sub GivePageCommonBorder()
Dim pgBorder As Double, shpsWidth As Double, shpsHeight As Double
Dim doc As Document
Dim pg As Page
Set doc = ActiveDocument
doc.Unit = cdrMillimeter
pgBorder = 20
Set pg = doc.ActivePage
' Select all shapes on the page
pg.Shapes.All.CreateSelection
shpsWidth = ActiveSelection.SizeWidth
shpsHeight = ActiveSelection.SizeHeight
' This is what I am lacking:
' Move the selection so its lower left corner has coordinates (pgBorder,pgBorder)
' Adjust page size
pg.SizeWidth = shpsWidth + 2 * pgBorder
pg.SizeHeight = shpsHeight + 2 * pgBorder
End Sub
祝福
Holger我偶然发现了.Move方法,并构建了以下解决方案:
Sub GivePageCommonBorder()
Dim pgBorder As Double
Dim doc As Document
Dim pg As Page
Set doc = ActiveDocument
doc.Unit = cdrMillimeter
pgBorder = 5
Set pg = doc.ActivePage
pg.Shapes.All.CreateSelection
With ActiveSelection
pg.SizeWidth = .SizeWidth + 2 * pgBorder
pg.SizeHeight = .SizeHeight + 2 * pgBorder
.Move pgBorder - .LeftX, pgBorder - .BottomY
End With
End Sub
霍尔格