Occurs when the user switches to a different item in a folder using the user interface (UI) or programmatically. This event also occurs when the user, either programmatically or using the UI, clicks or switches to a different folder that contains items as Microsoft Outlook automatically selects the first item in that folder. However, this event does not occur if the folder is a file-system folder or if Outlook Today or any folder with a current Web view is displayed. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).
Sub object_SelectionChange()
object An expression that evaluates to an Explorer object.
Example
This Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays the number of items selected in the active explorer window whenever the selection changes. The sample code must be placed in a class module, and the Initialize_handler
routine must be called before the event procedure can be called by Microsoft Outlook.
Dim myOlApp As New Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer
Public Sub Initialize_handler()
Set myOlExp = myOlApp.ActiveExplorer
End Sub
Private Sub myOlExp_SelectionChange()
MsgBox myOlExp.Selection.Count & " items selected."
End Sub