Outlook) (Table.Sort 方法

按 SortProperty 中指定的属性对表的行进行排序,并将当前行重置到表中第一行之前。

语法

表达式。排序 (SortProperty, 降序)

表达式 表示 Table 对象的变量。

参数

名称 必需/可选 数据类型 说明
SortProperty 必需 String 指定要使用的 表 的行进行排序的属性。
Descending 可选 Boolean 是否对 表 按降序进行排序。

备注

SortProperty 可以是任何显式内置属性或自定义属性,但二进制属性和多值属性除外。 属性必须通过其显式字符串名称进行引用;它不能通过命名空间进行引用。 有关指定排序属性的详细信息,请参阅 对文件夹中的项目排序。

对表排序等效于调用 MoveToStart 方法。 光标将定位到 Table 的开头。

如果先调用 Table.Sort 再调用 Table.Restrict,则新 Table 中的已筛选项目将按相同的 SortProperty 和 SortOrder 进行排序。

Table.Sort 仅支持单个列上排序。

示例

下面的代码示例演示如何基于 ReceivedTime 属性 表 中的行进行排序,并将打印排序表中每一行的 MAPI 规范化主题属性的值。

Sub SortTableByReceivedTime() 
 
 Dim oT As Outlook.Table 
 
 Dim oRow As Outlook.Row 
 
 Set oT = Session.GetDefaultFolder(olFolderInbox).GetTable 
 
 'Add normalized subject (subject without RE:, FW: and other prefixes)to the column set 
 
 oT.Columns.Add ("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") 
 
 
 
 'Sort by ReceivedTime in descending order 
 
 oT.Sort "[ReceivedTime]", True 
 
 
 
 Do Until oT.EndOfTable 
 
 Set oRow = oT.GetNextRow 
 
 'Print the normalized subject of each row 
 
 Debug.Print oRow("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") 
 
 Loop 
 
End Sub

另请参阅

表对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。