편집

다음을 통해 공유


Explorer.AddToSelection method (Outlook)

Adds the specified Microsoft Outlook item to the selection in the active explorer.

Syntax

expression.AddToSelection (Item)

expression A variable that represents an Explorer object.

Parameters

Name Required/Optional Data type Description
Item Required Object The item to add to the selection in the active explorer.

Remarks

The selection in the active explorer is represented by the Selection object that is returned by the Explorer.Selection property.

To be selected, the item must be selectable in the current view of the active explorer. Use the IsItemSelectableInView method to determine whether the item can be selected in the view. The item does not have to be visible in the view.

Under the following conditions, Outlook returns an error when you call the AddToSelection method:

  • The specified item is not in the current view of the active explorer.
  • The specified item is being edited in the current view of the active explorer.
  • The current view has been filtered, and the application of the filter removed the item from the view.
  • The specified item has not been saved.
  • The specified item represents a StorageItem.
  • No current view exists for the active explorer.

If the item is not selected and is selectable in the current view, calling AddToSelection causes the SelectionChange event to fire.

Calling AddToSelection does not scroll the view to make the selected item visible in the view and does not expand or collapse groups in the view.

The following table illustrates the results of calling AddToSelection, taking into consideration any current selection (the Selection.Count property), and whether the Reading pane is displayed.

Existing Selection.Count Reading pane displayed Results
0 Yes
  • The item is added to the selection.
  • SelectionChange fires.
  • Reading pane displays the item.
0 No
  • The item is added to the selection.
  • SelectionChange fires.
>=1 Yes
  • The item is added to the selection.
  • SelectionChange fires.
  • Reading pane does not change the item it displays unless the view is a Calendar view, in which case, calling AddToSelection can cause the Reading pane to display a different item.
>=1 No
  • The item is added to the selection.
  • SelectionChange fires.

If the specified item is already selected in the active explorer, calling AddToSelection does not result in any change to the selection, and the SelectionChange event does not fire.

When you specify an item in a recurring appointment or task as an argument to the AddToSelection method, make sure that before you pass the argument, you obtain an instance of the occurrence by first expanding the recurrences by using the IncludeRecurrences property and the Items collection. If you don't expand the recurrences and obtain an occurrence in the series, you pass an instance variable that represents the appointment or task series, and the AddToSelection method operates on the series instead of the occurrence.

Note that you can use AddToSelection to add items to a selection, but you cannot add conversation headers to a selection.

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.