IsFolderSelected Method
Returns a Boolean that determines if the folder is currently displayed in the explorer.
expression.IsFolderSelected(MAPIFolder)
*expression * Required. An expression that returns one of the objects in the Applies To list.
*MAPIFolder * Required. The MAPIFolder object representing the folder that is displayed in the explorer.
Example
This Microsoft Visual Basic for Applications (VBA) example closes a shared calendar that is displayed simultaneously with the current user's default Calendar folder. To run this example without errors, replace Dan Wilson with a valid recipient name whose calendar is shared and whose calendar you have permissions to view. You also need to display the shared calendar in Shared Calendar view. To do this, you can run the DispCalendars
procedure before running the CloseSharedCalendar
procedure.
Sub CloseSharedCalendar()
Dim myOlApp As Outlook.Application
Dim myNms As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim myExplorer As Outlook.Explorer
Dim SharedFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myExplorer = myOlApp.ActiveExplorer
Set myRecipient = myNms.CreateRecipient("Dan Wilson")
Set SharedFolder = myNms.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
If myExplorer.IsFolderSelected(SharedFolder) = True Then
myExplorer.DeselectFolder SharedFolder
End If
End Sub
Sub DispCalendars()
Dim myOlApp As Outlook.Application
Dim myNms As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myRecipient As Outlook.Recipient
Dim myExplorer As Outlook.Explorer
Dim SharedFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myFolder = myNms.GetDefaultFolder(olFolderCalendar)
Set myExplorer = myOlApp.ActiveExplorer
Set myExplorer.CurrentFolder = myFolder
Set myRecipient = myNms.CreateRecipient("Dan Wilson")
Set SharedFolder = myNms.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
myExplorer.SelectFolder SharedFolder
End Sub
Applies to | Explorer Object