Views.Remove Method (Outlook)

Removes an object from the collection.

Syntax

expression .RemoveIndex

expression A variable that represents a Views object.

Parameters

Name

Required/Optional

Data Type

Description

Index

Required

Variant

The name or 1-based index value of an object within a collection.

Example

The following example removes a View object from the Views collection.

Sub DeleteView() 
 
 'Deletes a view from the collection 
 
 Dim objName As Outlook.NameSpace 
 
 Dim objViews As Outlook.Views 
 
 Dim objView As Outlook.View 
 
 Dim strName As String 
 
 
 
 strName = "New Icon View" 
 
 Set objName = Application.GetNamespace("MAPI") 
 
 Set objViews = objName.GetDefaultFolder(olFolderNotes).Views 
 
 For Each objView In objViews 
 
 If objView.Name = strName Then 
 
 objViews.Remove (strName) 
 
 End If 
 
 Next objView 
 
End Sub

See Also

Concepts

Views Object

Views Object Members