The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

NameSpace.GetDefaultFolder Method

Office 2007
Returns a Folder object that represents the default folder of the requested type for the current profile, for example, obtains the default Calendar folder for the user who is currently logged on.



expression   A variable that represents a NameSpace object.


NameRequired/OptionalData TypeDescription
FolderTypeRequiredOlDefaultFoldersThe type of default folder to return.

Return Value
A Folder object that represents the default folder of the requested type for the current profile. If the default folder of the requested type does not exist, for example, because olFolderManagedEmail is specified as the

FolderType but the Managed Folders group has not been deployed, then GetDefaultFolder will return Null (Nothing in Visual Basic).


To return a specific non-default folder, use the Folders collection.


This Visual Basic for Applications (VBA) example uses the CurrentFolder property to change the displayed folder to the user's default Calendar folder.

Visual Basic for Applications
Sub ChangeCurrentFolder()
    Dim myNamespace As Outlook.NameSpace
    Set myNamespace = Application.GetNamespace("MAPI")
    Set Application.ActiveExplorer.CurrentFolder = _
End Sub

This VBA example returns the first folder in the Tasks Folders collection.

Visual Basic for Applications
Sub DisplayATaskFolder()
    Dim myNamespace As Outlook.NameSpace
    Dim myTasks As Outlook.Folder
    Dim myFolder As Outlook.Folder

    Set myNamespace = Application.GetNamespace("MAPI")
    Set myTasks = myNamespace.GetDefaultFolder(olFolderTasks)
    Set myFolder = myTasks.Folders(1)
End Sub

Community Additions

© 2014 Microsoft