Selection 属性

       

返回由在当前视图中所选项目组成的 Selection 对象。

expression.Selection

expression  必选。该表达式返回 Explorer 对象。

说明

如果当前文件夹是文件系统文件夹,或者当前显示的是“Outlook 今日”或具有当前 Web 视图的任何文件夹,该属性将返回空集。

示例

本 Microsoft Visual Basic/Visual Basic for Applications 示例使用由 Selection 属性返回的 Selection 集合的 Count 属性和 Item 方法来显示在活动的浏览器窗口中选定的所有邮件的发件人。

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
MsgTxt = "You have selected items from" & Chr(13) & Chr(13)
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
    MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & Chr(13)
Next x
MsgBox MsgTxt

如果使用 VBScript,则不必创建 Application 对象。本示例说明如何使用 VBScript 执行相同任务。

MsgTxt = "You have selected items from" & Chr(13) & Chr(13)
Set myOlSel = Application.ActiveExplorer.Selection
For x = 1 To myOlSel.Count
    MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & Chr(13)
Next 
MsgBox MsgTxt