View.GoToDate method (Outlook)

Changes the date used by the current view to display information.

Syntax

expression. GoToDate( _Date_ )

expression A variable that represents a View object.

Parameters

Name Required/Optional Data type Description
Date Required Date The date to which the view should be changed.

Remarks

To specify a date to go to in a current view, such as a CalendarView object, you should first obtain a View object for the current view by using Explorer.CurrentView instead of Folder.CurrentView. The following code sample demonstrates how to perform this action.

Sub TestGoToDate() 
 
 Dim oCV As Outlook.CalendarView 
 
 Dim oExpl As Outlook.Explorer 
 
 Dim datGoTo As Date 
 
 
 
 datGoTo = "11/7/2005" 
 
 
 
 ' Display the contents of the Calendar default folder. 
 
 Set oExpl = Application.Explorers.Add( _ 
 
 Application.Session.GetDefaultFolder(olFolderCalendar), olFolderDisplayFolderOnly) 
 
 oExpl.Display 
 
 
 
 ' Retrieve the current view by calling the 
 
 ' CurrentView property of the Explorer object. 
 
 Set oCV = oExpl.CurrentView 
 
 
 
 ' Set the CalendarViewMode property of the 
 
 ' current view to display items by day. 
 
 oCV.CalendarViewMode = olCalendarViewDay 
 
 
 
 ' Call the GoToDate method to set the date 
 
 ' for which information is displayed in the view. 
 
 oCV.GoToDate datGoTo 
 
End Sub

See also

View Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.