This code is based off of the macro used to always use the Tasks folder, not the To-Do List, when you switch folders in Outlook.
Use to it always open a specific folder when switching to the Contacts (or People) module.
To select a specific folder in the list, change the number in this line to open a different folder. For example, the code below opens the 4th folder in the My Contacts group as seen in the screenshot.
Set objGroup = objModule.NavigationGroups("My Contacts")
Set objNavFolder = objGroup.NavigationFolders.Item(4)Select folder macro
Dim WithEvents objPane As NavigationPane
Private Sub Application_Startup()
Set objPane = Application.ActiveExplorer.NavigationPane
End Sub
Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
Dim objModule As ContactsModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder
If CurrentModule.NavigationModuleType = olModuleContacts Then
Set objModule = objPane.Modules.GetNavigationModule(olModuleContacts)
' Use the Group name the folder is in
Set objGroup = objModule.NavigationGroups("My Contacts")
' Replace 4 with the index number of the folder you want to use
Set objNavFolder = objGroup.NavigationFolders.Item(4)
objNavFolder.IsSelected = True
End If
Set objNavFolder = Nothing
Set objGroup = Nothing
Set objModule = Nothing
End Sub
Opening specific folders in other navigation panes
You can use this method to default to a specific folder in other navigation panes.
| Module | Dim objModule As ? | olModule? |
|---|---|---|
| MailModule | olModuleMail | |
| Calendar | CalendarModule | olModuleCalendar |
| Contacts | ContactsModule | olModuleContacts |
| Tasks | TasksModule | olModuleTasks |
| Notes | NotesModule | olModuleNotes |
| Journal | JournalModule | olModuleJournal |
Replace the group name and index number with the group name the folder is in and it's position within the group.
Note: Mail works with the Favorites list.

