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

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

语法Syntax

expressionexpression. ActiveSelection

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

示例Example

下面的示例将每个所选任务的名称显示在一个消息框中。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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.