Hi all.
Having some VBA trouble with selections. The code below will select an ellipse in a group of selected shapes, but as soon as I use it with other (unselected) ellipse shapes on the same layer or page it selects the ellipse that is at the top of the layer heirarchy.
Sub Macro1() Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange Set s = ActivePage.FindShape(Type:=cdrEllipseShape) s.CreateSelectionEnd Sub
All I want to do is select the ellipse, or other named cdrShape from the currently selected shapes or group, not from the entire page or layer. Logically I would have assumed I just change ActivePage to ActiveSelection, but that doesn't work.
I'm sure this is simple but I cannot figure it out. Can anyone please point me in the right direction to selecting a cdrShape from the currently selected shapes or group.
Many thanks
Sark
ActiveSelection is a ShapeActiveSelectionRange is a ShapeRange
If you wish to work with the first matching shape in the selected ShapeRange, then you could use something likeset s = ActiveSelectionRange.Shapes.FindShape (Type:=cdrEllipseShape).
If all you want to do with it is to create a selection, then it could all be done in one line:
ActiveSelectionRange.Shapes.FindShape(Type:=cdrEllipseShape).CreateSelection.
Eskimo...Both are exactly what I was looking for. I tried ActiveSelection and ActiveSelectionRange instead of ActivePage, but I excluded Shapes.
Thanks for the clarification. It's appreciated.