伙计们,我是Coreldraw的VBA的新手,正在寻找一些帮助您选择名称的对象
我有两个对象1是曲线,一个是矩形。我用以下代码命名为OBJ1和OBJ 2
data.frame(Days=factor(days,levels=DescTools::day.abb), ...)
然后我尝试了以下代码来选择我需要做的两个对象,然后可以执行修剪
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
问题是结果是只有OBJ1被选中OBJ2仍然是联合国选中的
我确定它有些愚蠢,但希望您能提供帮助
谢谢
标记
答案 0 :(得分:1)
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