Selection Object (PowerPoint)
Published: July 16, 2012
Represents the selection in the specified document window. The Selection object is deleted whenever you change slides in an active slide view (the Type property will return ppSelectionNone).
Use the Selection property to return the Selection object. The following example places a copy of the selection in the active window on the Clipboard.
The following example sets the fill foreground color for the selected shapes in window two, assuming that there's at least one shape selected, and assuming that all selected shapes have a fill whose forecolor can be set.
With Windows(2).Selection.ShapeRange.Fill .Visible = True .ForeColor.RGB = RGB(255, 0, 255) End With
The following example sets the text in the first selected shape in window two if that shape contains a text frame.
With Windows(2).Selection.ShapeRange(1) If .HasTextFrame Then .TextFrame.TextRange = "Current Choice" End If End With
The following example cuts the selected text in the active window and places it on the Clipboard.
The following example duplicates all the slides in the selection (if you're in slide view, this duplicates the current slide).
If you don't have an object of the appropriate type selected when you use one of these properties (for instance, if you use the ShapeRange property when there are no shapes selected), an error occurs. Use the Type property to determine what kind of object or objects are selected. The following example checks to see whether the selection contains slides. If the selection does contain slides, the example sets the background for the first slide in the selection.