Application.ActiveSelection 属性 (Project)Application.ActiveSelection Property (Project)

获取表示活动选定内容的**所选内容** 对象。Gets a Selection object that represents the active selection. 只读的 所选内容Read-only Selection.


expressionexpression. ActiveSelection

_expression_表示应用对象的变量。expression A variable that represents an Application object.


下面的示例将每个所选任务的名称显示在一个消息框中。The following example displays the name of each selected task in a message box. 如果未进行有效选择就运行此示例,会产生一个可捕获的错误(错误代码为 424)。Running this example without a valid selection results in a trappable error (error code 424).

Sub SelectedTasks() 
 Dim T As Task 
 If Not (ActiveSelection.Tasks Is Nothing) Then 
 For Each T In ActiveSelection.Tasks 
 ' Test for blank task row 
 If Not (T Is Nothing) Then 
 MsgBox T.Name 
 End If 
 Next T 
 End If 
End Sub