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)
Pepi Huber says
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
Diane Poremsky says
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.
Suborno says
I ran a VB script and folders like Inbox and Archive got hidden.
Please help with a code to unhide them.
Bob Roberts says
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
Robert R says
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.
Diane Poremsky says
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
Robert R says
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)?
Diane Poremsky says
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
Paul says
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.
bhavani says
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
Simon says
Thanks for the article Diane.
Do you know if this code can be modified to navigate to search folders?
Thanks,
Simon
Diane Poremsky says
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.
Lukas says
Diane, did you find a way to create shortcuts for searching folders ?
Diane Poremsky says
No, i haven't found a way to do that. Sorry.
Lukas says
Taht's pitty. Anyway thank you for the response and greetings from Poland.
Geoff says
I Diane, thanks for your follow up message.
I did get it working shortly after my earlier posts as I found I had a typo in my code of the folder name.
I thank you very much for this code as it helped me greatly.
Best Regards
Geoff
Geoff says
Hi Diane, thank you for your reply.
I want to access a folder in a shared mailbox. That is, a folder in a Group Mailbox, that everybody thats been given permission can access. I dont know another way to explain it.
I can see here that Calender is considered a folder however I never considered it as that. To me folders are like the directory structure of Windows Explorer, and we set up a similar thing in Outlook with Sub-folders for storing emails by category etc. Calender is just a different part of outlook but not a folder.
I digress.
Anyway, with some trial and error I was able to get it working to access some Group mailboxes and sub folders using the scrip above you posted with the Function GetFolderPath
However its not working for personal folders I have on my D drive and I can't figure out which example script would best fit this case.
I tried...
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
with the GetFolderPath function I already have for accessing the Group folders but it gives an error which I can't remember at the moment cause I'm finished for the day. I will try again and note the error here tomorrow.
Thankyou for your dedicated assistance.
Geoff
Diane Poremsky says
GetFolderpath works with pst files. As long as the pst name and folder path is correct - display-name\Inbox\Test - it'll work. I'm not sure why it's not working for you
Geoff says
Hi Diane, I've recently upgraded to Office 2013 and the text input of the Goto dialogue (Office 2007) is no longer available. I've used your code to make Quick Access shortcuts to some local folders but I'm unable to get it working for Group folders. I need to make a shortcut to goto a folder called \\Mailbox - ! Customer Number Range Management\ISDN30
I think your scripts look exactly what I'm looking for to restore some funcanality I've lost.
I tried this...
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
but I think it needs to be used with this...
Use a shared folder (Exchange mailbox)
To access a shared folder in another user's Exchange server mailbox, you need to use GetSharedDefaultFolder to reference the mailbox, after resolving the address to the folder.
You can use the mailbox owner's display name, alias, or email address when resolving the recipient.
Dim NS As Outlook.NameSpace
Dim objOwner As Outlook.Recipient
Set NS = Application.GetNamespace("MAPI")
Set objOwner = NS.CreateRecipient("maryc")
objOwner.Resolve
If objOwner.Resolved Then
'MsgBox objOwner.Name
Set newCalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
End If
I can't see how Calender is relevant so its confusing me. I want to make quick access shortcuts to quickly goto the various email folders I work from.
Could you assist me to get this working please?
Best regards
Geoff
Diane Poremsky says
For other folders, you need to change this line:
Set newCalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
to use the correct folder.
Is the folder in your profile as a shared mailbox or open as a shared folder?
Diane Poremsky says
If this mailbox is open as a shared mailbox, this should work (it does here - I'm caching shared folders)
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("Mailbox - ! Customer Number Range Management\ISDN30")
Set objOlApp.ActiveExplorer.CurrentFolder = objFolder
Set objFolder = Nothing
Set objOlApp = Nothing
End Sub
if you want to open it in a new window, use
objFolder.Display instead if the currentfolder line.
Anton M says
Thank you, very useful!