共用方式為


View.XML (Outlook)

會傳回或設定指定目前檢視之 XML 定義的 String 值。 讀取/寫入。

語法

表情XML

一個代表 View 物件的變數。

註解

XML 定義會使用一系列對應檢視本身各種屬性的標籤及關鍵字,說明檢視類型。 在建立檢視時,會解析 XML 定義,呈現新檢視的設定。

若要判斷建立檢視時 XML 的結構方式,您可以使用 Outlook 使用者介面建立檢視,然後擷取該檢視的 XML 屬性。

若要程式化地將自訂欄位加入檢視,請使用 ViewFields 物件的 Add 方法。 這是建議動態更改視圖的方式,而非設定視圖物件的 XML 屬性。

範例

以下Microsoft Visual Basic for Applications (VBA) 範例,建立 Views 集合的實例,並顯示名為「Table View」的視圖的 XML 定義。 若檢視不存在,則會建立一個。

Sub DisplayViewDef() 
 
 'Displays the XML definition of a View object 
 
 Dim objName As Outlook.NameSpace 
 
 Dim objViews As Outlook.Views 
 
 Dim objView As Outlook.View 
 
 
 
 Set objName = Application.GetNamespace("MAPI") 
 
 Set objViews = objName.GetDefaultFolder(olFolderInbox).Views 
 
 'Return a view called Table View if it already exists, else create one 
 
 Set objView = objViews.Item("Table View") 
 
 If objView Is Nothing Then 
 
 Set objView = objViews.Add("Table View", olTableView, olViewSaveOptionAllFoldersOfType) 
 
 End If 
 
 MsgBox objView.XML 
 
End Sub

以下是下列 XML 原始程式碼中顯示的已修改屬性。 除了屬性定義外,XML 原始碼也定義了構成視圖的任何物件。 在下列範例中,會顯示上方檢視中所出現之欄的 XML 定義。

<heading>Flag Status</heading>     <prop>http://schemas.microsoft.com/mapi/proptag/0x10900003</prop>     <type>i4</type>     <bitmap>1</bitmap>     <style>padding-left:3px;text-align:center;padding-left:3px</style> </column> <column>     <format>boolicon</format>     <heading>Attachment</heading>     <prop>urn:schemas:httpmail:hasattachment</prop>     <type>boolean</type>     <bitmap>1</bitmap>     <style>padding-left:3px;text-align:center;padding-left:3px</style>     <displayformat>3</displayformat> </column>

另請參閱

View 物件

支援和意見反應

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