ViewRemove Event

Microsoft Outlook Visual Basic

Sub expression_ ViewRemove(ByVal View As View)

expression     A variable which references an object of type Views declared with events in a class module.

View       The view which was removed from the collection prior to this event.

Example

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays the name of the view that has been removed from the collection when the ViewRemove event is fired. The sample code must be placed in a class module such as ThisOutlookSession, and the DeleteView() procedure should be called before the event procedure can be called by Microsoft Outlook.

Public WithEvents objViews As Outlook.Views

Sub DeleteView()
	Dim myolapp As New Outlook.Application
	Set objViews = myolapp.Application.ActiveExplorer.CurrentFolder.Views
	objViews.Item("New Table View").Delete
End Sub

Sub objViews_ViewRemove(ByVal View As View)
	'Displays view name
	MsgBox "The view: " & View.Name & " was removed programmatically."
End Sub