CustomViewsOnly 属性

       

返回或设置指定文件夹的“视图”菜单上所显示的视图。Boolean 类型。如果设置为 True,菜单上将只显示用户创建的视图。可读写。

expression.CustomViewsOnly

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

示例

以下示例提示用户选择视图选项。如果用户选择查看所有的视图,则将 CustomViewsOnly 属性设置为 False。如果用户选择只查看自定义的视图,则将 CustomViewsOnly 属性设置为 True。属性更改后,更改的结果就会显示给用户。

Sub SetCusView()
'Sets the CustomViewsOnly property depending on the user's response

    Dim olApp As Outlook.Application
    Dim nmsName As NameSpace
    Dim fldFolder As MAPIFolder
    Dim lngAns As Long

    Set olApp = Outlook.Application
    Set nmsName = olApp.GetNamespace("MAPI")
    Set fldFolder = nmsName.GetDefaultFolder(olFolderInbox)

    'Prompt user for input
    lngAns = MsgBox("Would you like to view only custom views in the view menu?", vbYesNo)

    Call SetVal(fldFolder, lngAns)

End Sub

Sub SetVal(ByRef fldFolder As MAPIFolder, ByVal lngAns As Long)
'Modifies the CustomViewsOnly property to display views on the Views menu

    If lngAns = vbYes Then
        fldFolder.CustomViewsOnly = True
    Else
        fldFolder.CustomViewsOnly = False
    End If

    'Display only custom views
    If lngAns = vbYes Then
       MsgBox "The " & fldFolder.Name & " folder will now display only custom views."
    'display all views
    Else
       MsgBox "The " & fldFolder.Name & " folder will now display all views."
    End If

End Sub