Parsing selected shapes

Parsing through the selected shapes is done in the same way for both selections and selection ranges. Here is a code sample for selections:

Dim shs As Shapes, sh As Shape Set shs = ActiveSelection.Shapes For Each sh In shs

Do something with the shape, sh

Next sh

And here is a code sample for selection ranges:

Dim sRange As ShapeRange, sh As Shape Set sRange = ActiveSelectionRange For Each sh In sRange

' Do something with the shape, sh Next sh

However, selection ranges have the advantage that even if the selection subsequently changes, the range is not updated, and so the "memory" of the selection is not lost. Getting a reference to the ActiveSelection, though, does not create a copy of the references to the shapes in the selection, but creates a reference to the intrinsic ActiveSelection object. This means that if the selection changes, all references to the ActiveSelection are also updated, and so the "memory" of the selection is lost.

0 0

Post a comment

  • Receive news updates via email from this site