Guys I am new to VBA for Coreldraw and am searching for some help in selecting multiple objects by name
I have two objects 1 is a curve and one is a rectangle. I name them OBJ1 & OBJ 2 with the following Code
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
I Then have tried the following code to select the two objects which I need to do so I can then perform a trim
Dim s as Shape
ActiveDocument.ClearSelection
Set s = ActivePage.FindShape(Name:="OBJ1")
ActivePage.FindShape(Name:="OBJ2").AddToSelection
s.CreateSelection
Problem is the result is that only OBJ1 is selected OBJ2 remains UN-selected
I'm sure its something stupid but would appreciate any help you could give
Thanks
Mark
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