CoreldrawVBA Select 多个对象(按名称)
CoreldrawVBA Select multiple Objects by Name
伙计们,我是 VBA Coreldraw 的新手,正在寻找一些帮助select按名称编辑多个对象
我有两个对象,一个是曲线,一个是矩形。我用以下代码将它们命名为 OBJ1 和 OBJ 2
For Each s In sr.Shapes
objName = s.Name
objName = "OBJ1"
If objName <> "" Then
s.Name = objName
End If
Next s
For Each s In sr.Shapes
objName = s.Name
objName = "OBJ2"
If objName <> "" Then
s.Name = objName
End If
Next s
然后我尝试了以下代码 select 我需要这样做的两个对象然后我可以执行 trim
Dim s as Shape
ActiveDocument.ClearSelection
Set s = ActivePage.FindShape(Name:="OBJ1")
ActivePage.FindShape(Name:="OBJ2").AddToSelection
s.CreateSelection
问题是结果是只有 OBJ1 被 selected OBJ2 仍然是 UN-selected
我敢肯定它有些愚蠢,但如果你能提供任何帮助,我将不胜感激
谢谢
马克
Sub Test()
CreateSelectionByNames Array("OBJ1", "OBJ2")
End Sub
Sub CreateSelectionByNames(aNames)
Dim sName
Dim shpRange As New ShapeRange
For Each sName In aNames
shpRange.Add ActivePage.FindShape(Name:=sName)
Next
shpRange.CreateSelection
End Sub
伙计们,我是 VBA Coreldraw 的新手,正在寻找一些帮助select按名称编辑多个对象
我有两个对象,一个是曲线,一个是矩形。我用以下代码将它们命名为 OBJ1 和 OBJ 2
For Each s In sr.Shapes
objName = s.Name
objName = "OBJ1"
If objName <> "" Then
s.Name = objName
End If
Next s
For Each s In sr.Shapes
objName = s.Name
objName = "OBJ2"
If objName <> "" Then
s.Name = objName
End If
Next s
然后我尝试了以下代码 select 我需要这样做的两个对象然后我可以执行 trim
Dim s as Shape
ActiveDocument.ClearSelection
Set s = ActivePage.FindShape(Name:="OBJ1")
ActivePage.FindShape(Name:="OBJ2").AddToSelection
s.CreateSelection
问题是结果是只有 OBJ1 被 selected OBJ2 仍然是 UN-selected
我敢肯定它有些愚蠢,但如果你能提供任何帮助,我将不胜感激
谢谢
马克
Sub Test()
CreateSelectionByNames Array("OBJ1", "OBJ2")
End Sub
Sub CreateSelectionByNames(aNames)
Dim sName
Dim shpRange As New ShapeRange
For Each sName In aNames
shpRange.Add ActivePage.FindShape(Name:=sName)
Next
shpRange.CreateSelection
End Sub