Noprobo

Saving Time in Outlook with Custom Move-To-Folder Shortcuts

December 24th, 2008

With the popularity of email management philosophies like Getting Things Done (GTD) and Inbox Zero, more people find themselves dragging and dropping hundreds of emails into subfolders. This is a tedious process and one Outlook is not well designed to accommodate, especially when dealing with a high flow of correspondence. The best Outlook can offer is to automate this is the “Move to Folder” pop-up window (Ctrl+Shift+V, [Select Folder], Enter) which is only marginally faster than using the drag-and-drop method.

The perfect solution would be one where a quick, single keystroke gets the selected email(s) to their destination. No fuss, no muss, move on to the next.

Fortunately there’s an easy way to do this up using Outlook’s macros and a little know-how. This article will show non-programmers how to painlessly set this up in less than five minutes.

This guide is based on Outlook 2003 in Windows XP. It has also been tested on Outlook 2000 and 2007 in Windows XP. Your mileage may vary.

How-To

This example will show in detail how to make selected email go to a subfolder entitled “Archive” upon pressing Alt+X:

  1. In Outlook press Ctrl+1 to go to the Inbox
  2. Press Ctrl+Shift+E to create a new folder named “Archive” under the Inbox
  3. Press Alt+F11 to open the Visual Basic editor
  4. Select “ThisOutlookSession” under “Project 1″ > “Microsoft Office Outlook”
  5. Press F7 to open a “View Code” window
  6. Cut and paste the following code into the main “View Code” window:
  7. ' This/These macro(s) implement the procedure for different folders
    Sub MoveSelectedMessagesToArchive()
        MoveSelectedMessagesToFolder ("Archive")
    End Sub
    
    ' This macro does the heavy lifting, and is only called from another VBA procedure
    Sub MoveSelectedMessagesToFolder(FolderName As String)
    
    'On Error Resume Next
        Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
        Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
    
        Set objNS = Application.GetNamespace("MAPI")
        Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
        Set objFolder = objInbox.Folders(FolderName)
    
    'Assume this is a mail folder
    
        If objFolder Is Nothing Then
            MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
        End If
    
        If Application.ActiveExplorer.Selection.Count = 0 Then
            'Require that this procedure be called only when a message is selected
            Exit Sub
        End If
    
    	If Application.ActiveExplorer.Selection(1).Class = 43 Then
        ' 43 is the literal constant for a mail item
        ' sometimes a calendar item is in the inbox, in which case there is a type
        ' conflict with the objItem variable, which is declared as a mail item.
    
           For Each objItem In Application.ActiveExplorer.Selection
               If objFolder.DefaultItemType = olMailItem Then
                   If objItem.Class = olMail Then
                        objItem.UnRead = False
                        objItem.Move objFolder
                   End If
               End If
           Next
        Else
            MsgBox ("This is not a message; it may be a calendar request")
        End If
    
        Set objItem = Nothing
        Set objFolder = Nothing
        Set objInbox = Nothing
        Set objNS = Nothing
    
    End Sub
    

    (original code source)

  8. Hit Ctrl+S to save the modified code
  9. Close the “Microsoft Visual Basic” window
  10. In Outlook press Alt-T then press C to customize the toolbar
  11. On the “Commands” Tab, under “Categories”, select “Macros”
  12. Drag and drop “Project1.ThisOutlookSession.MoveSelectedMessagesToFolder” to wherever you would like it on the toolbar
  13. Leaving the “Customize” window open, give your button a nicer name and a shortcut key by right clicking on your new button in toolbar and entering “&x Archive” — the ampersand-x (”&x”) will make the letter “x” the shortcut key
  14. Close the “Customize” window.
  15. Allow Outlook to run the shortcut with your permission by selecting “Tools” > “Macros” > “Security” (or Alt+T, M, S) and selecting security level “Medium”
  16. Restart Outlook and try it out: select an email and press Alt-X

The first time you run the shortcut Outlook will ask your permission to allow it to happen. Select “Enable Macros” and you’re off to the races!

Repeatability

Modifying the code to work with multiple folders doesn’t require a professional programmer. You can simply add another entry to the very top of the code by hitting F11 in Outlook and pasting:

Sub MoveSelectedMessagesToFolderName()
	MoveSelectedMessagesToFolder ("FolderName")
End Sub

Change the underlined parts to match the name of your new folder, create another shortcut button on the toolbar and Bob’s your uncle.

Count Your Pennies

When it comes to saving money you need to count your pennies as well as your dollars. The same goes for time management; saving seconds over and over again which add up to hours. I have been using this same code for years, migrating it from Outlook 2000 to 2003 to 2007 to 2003 again and it has served me well. Hopefully this guide has given you an opportunity to free up some of the mental baggage that comes with a bursting inbox. It has for me!

Home | Top | Contact © 2008-2010 Noprobo | Legal