Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Selection Object

Office 2007
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).

Example

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.

Visual Basic for Applications
ActiveWindow.Selection.Copy

Use the ShapeRange , SlideRange , or TextRange property to return a range of shapes, slides, or text from the selection.

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.

Visual Basic for Applications
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.

Visual Basic for Applications
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.

Visual Basic for Applications
ActiveWindow.Selection.TextRange.Cut

The following example duplicates all the slides in the selection (if you're in slide view, this duplicates the current slide).

Visual Basic for Applications
ActiveWindow.Selection.SlideRange.Duplicate

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.

Visual Basic for Applications
With Windows(2).Selection
    If .Type = ppSelectionSlides Then
        With .SlideRange(1)
            .FollowMasterBackground = False
            .Background.Fill.PresetGradient _
                msoGradientHorizontal, 1, msoGradientLateSunset
        End With
    End If
End With



Community Additions

Show:
© 2015 Microsoft