共用方式為


Outlook) (Table.Sort 方法

SortProperty中指定的屬性排序Table的資料列,並將目前資料列重設為Table中第一個資料列之前。

語法

運算式SortPropertyDescending ()

表達 代表 Table 物件的變數。

參數

名稱 必要/選用 資料類型 描述
SortProperty 必要 字串 會指定要用來排序 Table 之列的屬性。
選用 布林值 是否要以遞減順序排序 Table

註解

SortProperty 可以是任何明確內建屬性或自訂屬性,但二進位和多重值屬性除外。 您必須依明確字串名稱參照此屬性,而不能依命名空間參照屬性。 如需指定排序屬性的詳細資訊,請參閱 排序資料夾中的專案

排序資料表相當於呼叫 MoveToStart 方法。 游標的位置將調整為表格的開頭。

如果先呼叫 Table.Sort,然後再呼叫 Table.Restrict,新 Table 中的篩選項目將會依據相同的 SortPropertySortOrder 進行排序。

Table.Sort 僅支援在單一欄上進行排序。

範例

下列程式碼範例會說明如何根據 ReceivedTime 屬性,排序 Table 中的列,並針對排序表格中的每一列,列印 MAPI 標準化 Subject 屬性的值。

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

另請參閱

Table 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應