Application.ActiveSelection Property

Project Developer Reference

Returns a Selection object that represents the active selection. Read-only Object.

Syntax

expression.ActiveSelection

expression   A variable that represents an Application object.

Return Value
Selection

Example
The following example displays the name of each selected task in a message box. Running this example without a valid selection results in a trappable error (error code 424).

Visual Basic for Applications
  Sub SelectedTasks()
Dim T As Task

If Not (<strong class="bterm">ActiveSelection</strong>.Tasks Is Nothing) Then
    For Each T In <strong class="bterm">ActiveSelection</strong>.Tasks
        ' Test for blank task row
        If Not (T Is Nothing) Then
            MsgBox T.Name
        End If
    Next T
End If

End Sub

See Also