Explorer.Selection property (Outlook)

Returns a Selection object that contains the item or items that are selected in the explorer window. Read-only.



expression A variable that represents an 'Explorer' object.


The location of a selection in the explorer can be in the view list, the appointment list or task list in the To-Do Bar, or the daily tasks list in a calendar view. For more information, see the Location property.

The Selection property does not include any conversation header objects. Call the Selection.GetSelection method, providing olConversationHeaders as the argument, to obtain conversation header objects that are selected in the explorer.

If the current folder displays a folder home page, this property returns an empty collection. Also, if a group header such as Today, or a conversation group header is selected, the Count property on the returned Selection object is zero.


The following Microsoft Visual Basic for Applications (VBA) example displays the sender of each selected item in the active explorer. It uses the Count property and the Item method of the Selection object that is returned by the Explorer.Selection property to display the senders of all messages that are selected in the active explorer.

Sub GetSelectedItems() 
 Dim myOlExp As Outlook.Explorer 
 Dim myOlSel As Outlook.Selection 
 Dim mySender As Outlook.AddressEntry 
 Dim oMail As Outlook.MailItem 
 Dim oAppt As Outlook.AppointmentItem 
 Dim oPA As Outlook.PropertyAccessor 
 Dim strSenderID As String 
 Dim MsgTxt As String 
 Dim x As Long 
 MsgTxt = "Senders of selected items:" 
 Set myOlExp = Application.ActiveExplorer 
 Set myOlSel = myOlExp.Selection 
 For x = 1 To myOlSel.Count 
 If myOlSel.Item(x).Class = OlObjectClass.olMail Then 
 ' For mail item, use the SenderName property. 
 Set oMail = myOlSel.Item(x) 
 MsgTxt = MsgTxt & oMail.SenderName & ";" 
 ElseIf myOlSel.Item(x).Class = OlObjectClass.olAppointment Then 
 ' For appointment item, use the Organizer property. 
 Set oAppt = myOlSel.Item(x) 
 MsgTxt = MsgTxt & oAppt.Organizer & ";" 
 ' For other items, use the property accessor to get the sender ID, 
 ' then get the address entry to display the sender name. 
 Set oPA = myOlSel.Item(x).PropertyAccessor 
 Set mySender = Application.Session.GetAddressEntryFromID(strSenderID) 
 MsgTxt = MsgTxt & mySender.Name & ";" 
 End If 
 Next x 
 Debug.Print MsgTxt 
End Sub

See also

Explorer 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.