Always open Contacts to a specific Contacts folder

Last reviewed on May 16, 2014   —  2 comments

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.

Contacts indexUse 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.

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.

ModuleDim objModule As ?olModule?
MailMailModuleolModuleMail
CalendarCalendarModuleolModuleCalendar
ContactsContactsModuleolModuleContacts
TasksTasksModuleolModuleTasks
NotesNotesModuleolModuleNotes
JournalJournalModuleolModuleJournal

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.

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

2 responses to “Always open Contacts to a specific Contacts folder”

  1. ianandrews999

    I would like to open several Outlook default folders - eg calendar, contacts etc - AND launch each in a new window. Every folder displays its own icon, making it easy to identify with ALT-TAB, if I open it manually, (right click, open in new window). However, every folder displays the same inbox icon, making it difficult to identify with ALT-TAB, if I open it programmatically in vba, using the following code:

    +++++++
    Sub openfolderwindows()

    On Error Resume Next
    Dim NS As Outlook.NameSpace
    Dim Folders As Outlook.Folders
    Dim F As Outlook.MAPIFolder
    Dim ExpandDefaultStoreOnly As Boolean

    'which folders should be opened?
    '(false = all +/- conditions; true = personal folders only)
    ExpandDefaultStoreOnly = True
    Set NS = Application.GetNamespace("Mapi")

    If ExpandDefaultStoreOnly = True Then
    'open personal folders only
    Set F = NS.GetDefaultFolder(olFolderInbox)
    Set F = F.Parent
    Set Folders = F.Folders
    loopwindows Folders, True
    Else
    'open all folders
    loopwindows NS.Folders, True
    End If

    DoEvents

    End Sub
    Sub loopwindows(Folders As Outlook.Folders, ByVal bRecursive As Boolean)

    For Each F In Folders
    Set Application.ActiveExplorer.CurrentFolder = F
    If F = "Outbox" Or F = "Calendar" Or F = "Contacts" Or F = "Tasks" Then
    F.Display
    DoEvents
    If bRecursive Then
    If F.Folders.count Then
    loopwindows F.Folders, bRecursive
    End If
    End If
    End If
    Next

    End Sub

    +++++++

    Although the same folders that were open in the last session should appear when restarting Outlook, the program crashes too often to rely on this. I've also seen information about setting a custom icon for Outlook folders; but not all accept custom icons - in particular the default folders.

    I'm using Outlook 2010 at present but just about to upgrade to 2013. Can anyone help?

Leave a Reply

If the Post Coment button disappears, press your Tab key.