The current versions do not support creating shortcuts on your desktop to the Outlook folders. Outlook doesn't support creating shortcuts to folders on the Quick Access toolbar (QAT) or ribbon, but you can put macro on the QAT or ribbon that opens a folder.
But you can create shortcuts to open folders, using one of these options, in my order of preference:
- Add the folder to Outlook's Favorites
- Use a macro on the QAT or ribbon
- Use VBScript or PowerShell to open the folder
- Create a shortcut on the Shortcut navigation pane
Tip: Using a shortcut on the Shortcut nav pane is a two-step process, add it to Favorites in Mail instead. The exception would be if you constantly jump between specific folders, including contacts, calendar and tasks and you want a simplified Folder list view
To use these macros
Go to File, Options, Trust Center,Macro Settings and set macro security to low for now. After you are finished creating and testing the macros, you can use Selfcert to sign the macros and change the settings to only signed macros.
- Open the VBA editor using Alt+F11
- Right-click on Project1 and choose Insert Module
- Paste the appropriate macro into the new module
- Change the macro name
- Correct the folder names as needed
- Repeat steps 3, 4, and 5 as needed. You can use one module for all of these macros.
In Outlook:
- Go to File, Options
- Select Customize Ribbon or Quick Access Toolbar
- Select Macros from the Choose Commands From dropdown
- If adding it to the ribbon, add a New Group or a New Tab and New Group
- Select your macro and click Add
Open a default folder
This code sample opens a default folder, the Junk Email folder in this example.
Sub openJunkFolder() Dim objOlApp As Outlook.Application Set objOlApp = CreateObject("Outlook.Application") Dim objFolder As Outlook.Folder Set objFolder = Session.GetDefaultFolder(olFolderJunk) Set objOlApp.ActiveExplorer.CurrentFolder = objFolder Set objFolder = Nothing Set objOlApp = Nothing End Sub
To open Exchange public folders, you'll use the GetDefaultFolder method and to get the olPublicFoldersAllPublicFolders folder type. Walk to subfolders using the same method used for mailbox subfolders.
Set objFolder = Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("my folder")
Default Folder | Use with GetDefaultFolders |
---|---|
Inbox | olFolderInbox |
Calendar | olFolderCalendar |
Contacts | olFolderContacts |
Tasks | olFolderTasks |
To-Do List | olFolderToDo |
Sent Items | olFolderSentMail |
Outbox | olFolderOutbox |
Notes | olFolderNotes |
Drafts | olFolderDrafts |
Junk Email | olFolderJunk |
Deleted Items | olFolderDeletedItems |
All Public Folders | olPublicFoldersAllPublicFolders |
Open a subfolder of a default folder
Use this code sample to open a subfolder under one of Outlook's default folders.
Sub openSubFolder() Dim objOlApp As Outlook.Application Dim objFolder As Outlook.Folder Set objOlApp = CreateObject("Outlook.Application") Set objFolder = Session.GetDefaultFolder(olFolderInbox).Folders("subfolder name") Set objOlApp.ActiveExplorer.CurrentFolder = objFolder Set objFolder = Nothing Set objOlApp = Nothing End Sub
To open nested subfolders, add Folders("foldername") as needed:
Set objFolder = Session.GetDefaultFolder(olFolderInbox).Folders("subfolder name").Folders("subfolder name")
Open a folder at the same level as the default folders
This code sample opens a folder at the same level as the Inbox. Add .Folders("Folder name") as needed to locate nested subfolders.
Sub openOtherFolder() Dim objOlApp As Outlook.Application Dim objFolder As Outlook.Folder Set objOlApp = CreateObject("Outlook.Application") Set objFolder = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Subfolder name") Set objOlApp.ActiveExplorer.CurrentFolder = objFolder Set objFolder = Nothing Set objOlApp = Nothing End Sub
Open a folder in another data file
If you need a shortcut to a folder in another data file, you'll need to use the GetFolderPath function with the data file display name and the path to the folder.
Add the function to the bottom of the module. The one function can be used with any macro that needs it.
Sub openOtherPST() Dim objOlApp As Outlook.Application Dim objFolder As Outlook.Folder Set objOlApp = CreateObject("Outlook.Application") ' Get GetFolderPath Function from http://slipstick.me/qf#GetFolderPath Set objFolder = GetFolderPath("display-name\Inbox\Test") Set objOlApp.ActiveExplorer.CurrentFolder = objFolder Set objFolder = Nothing Set objOlApp = Nothing End Sub
Use with several folders
If you want to create shortcuts for multiple folders, use this code sample. It's more compact and easier to read compared to repeating the full macros for each folder.
To use these macros, copy the openInbox macro, changing the name and the folder path. Add the open macros to the ribbon or Quick Access toolbar.
Public objfolder As Outlook.MAPIFolder Sub openInbox() Set objfolder = Session.GetDefaultFolder(olFolderInbox) openOutlookFolder End Sub Sub openTest() Set objfolder = Session.GetDefaultFolder(olFolderInbox).Folders("Test") openOutlookFolder End Sub Private Sub openOutlookFolder() Dim objOlApp As Outlook.Application Set objOlApp = CreateObject("Outlook.Application") Set objOlApp.ActiveExplorer.CurrentFolder = objfolder Set objOlApp = Nothing End Sub
How to use the macros on this page
First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.
The macros on this page should be placed in a module.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor
More Information
OlDefaultFolders Enumeration (MSDN)
Working with VBA and non-default Outlook Folders
Folder: Find a folder by its name (VBOffice.net)
Hi Diane, thanks so much, great code. I use it to show a Search Folder. This works well and shows all eMails covered by the search folder.
There is one catch I could not solve. The search folder is not selected in the navigation pane for Mails. When I use Folder view all is fine, the emails show up and the search folder is being selected (visually) in the Folder view. In the Mail view of the navigation pane the eMails show up correctly but the Search folder is not selected - no folder is selected in the navigation pane. I tried to refresh the view from VBA to correctly show the search folder selected in the navigation pane for Mails, but not successful. If you have a hint I would be grateful! Thanks, Pepi
I'll test it and see if i can figure out why it's not working as you expect and if there is a way to fix it.
I ran a VB script and folders like Inbox and Archive got hidden.
Please help with a code to unhide them.
Diane, your site is super!
Just what I needed, again; "Open a folder at the same level as the default folders"
There have been other times when I was lost in the woods and your guidance was spot on.
Thank you,
Bob
Sorry, I misspoke ... the nested folder resides in a Outlook Personal Archive (not an .ost file). The archive path is "\Archive_MktProjects". Thanks in advance.
Sorry I missed this earlier - i was swamped and am now trying to get caught up. It doesn't matter what the data type is, only if its in the default data file or in a different file - if its not in the default, you need to use the getfolderpath function.
https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/#GetFolderPath
Hi there, can you help me to modify your code to access a nested folder in an .ost archive file (my nested folder does not reside within the inbox folder)?
If it's not in the default data file, you need to use
Set objFolder = GetFolderPath("Archive_MktProjects\folder-name")
You need the getfolderpath function from https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/#GetFolderPath
Hello. I have been looking at your macros but unfortunately none are adapted to what I need. I would need to open through the ribbon one or several data files that are NOT currently loaded in outlook and that are located in a non-default location. How would I do that?
Note: The data files are purposely not loaded when outlook launches as those data files are archives and I do not want them to be loaded each time outlook starts. I only need them when it is required through a shortcut in the ribbon. I know there is a command called "Open Outlook Data Files..." but that command seems to be hard coded with the default path C:Users[user_account]DocumentsOutlook Files so it is useless to me.
Thanks in advance for the help.
I have a requirement wherein i have 10 mail accounts. I want the COLLAPSE VIEW of the Mailboxes itself which is not there in outlook now. Even if i make fvavorites its only Inbox, outbox which is very cumbersome. I want collapse and expand view of hte mail accounts themselves so that when we want to click that mailbox it gives that view only. now we have to navigate very deep deeper until we reach our mailbox acct. Hope somebody can help. I am even ready to pay a small token fee for htis. in outlook. pls help
Thanks for the article Diane.
Do you know if this code can be modified to navigate to search folders?
Thanks,
Simon
No, i don't think so - search folders are virtual folder and don't have a path like other folders. But I'll take a look and see if there is a way to do it.
Diane, did you find a way to create shortcuts for searching folders ?
No, i haven't found a way to do that. Sorry.
Taht's pitty. Anyway thank you for the response and greetings from Poland.