_CalendarView.SelectedEndTime Property

Returns a DateTime value that represents the end time of a selection in the CalendarView object. Read-only.

Namespace:  Microsoft.Office.Interop.Outlook
Assembly:  Microsoft.Office.Interop.Outlook (in Microsoft.Office.Interop.Outlook.dll)

DateTime SelectedEndTime { get; }

Property Value

Type: System.DateTime

The intent of the SelectedStartTime and the SelectedEndTime properties is to replicate, programmatically, the way that users create an appointment in the Microsoft Outlook user interface. Typically, a user selects a time range in the calendar view and then creates a new appointment by double clicking the selection or by clicking New Appointment in the Home tab of the Microsoft Office Fluent ribbon. With these two properties of the CalendarView object, you can obtain the start time and the end time of any selection in that view programmatically. You can then programmatically create the AppointmentItem object, setting the Start and End properties of the AppointmentItem object to the SelectedStartTime and SelectedEndTime properties respectively to reflect any user selection in the calendar view.

If the selection in the calendar view is a time range and is not an item, SelectedEndTime returns a DateTime value equal to the end time of the selection.

If one or more items are selected in the calendar view, SelectedEndTime returns a DateTime value equal to the end time of the first item in the selection of the explorer that displays the calendar view. That selection is specified by the Selection property of the Explorer object.

To use this property on a CalendarView object, obtain the CalendarView object from the CurrentView property of the active Explorer object (which can be returned by the ActiveExplorer() method). There is a known issue with using this property on an CalendarView object obtained otherwise - using the CurrentView property of the current Folder object (returned by the CurrentFolder property of the object represented by Application.ActiveExplorer).