A couple of years ago, or so, I bought a mouse with a ludicrous number of buttons on it. The life of the Razer Naga MMO is intended to be spent helping its owner slay monsters in video games. The five top buttons and twelve side buttons can seem overwhelming at first. But all seventeen can be put to good use after some practice, even at the office.
After seeing its advantages in gaming, I decided to take the mouse to work and see if it could be of use there. I found it to be of minimal use in a number of applications. The number pad on the side is only semi-useful in terminal sessions when its twelve buttons are mapped perfectly to your F1 through F12 keys, but I tend to need to use an F-key the most while typing with both hands on the keyboard.
The place where I found that it shined the most was in Outlook. It may not turn your inbox in to a video game, but it can help you file emails faster and save you from dropping items in the wrong folder. By automating tasks with VBA macros and invoking them with the mouse, you can really make Outlook bow to your will.
Setting up folders
One of the things to do first when you want to get around to organizing your mailbox is to come up with a folder structure that makes sense to you. I created a root folder simply named with an at-sign. This symbol keeps it at the top of the folder list where it can easily be found. Then the rest of the folders that I use can go in a sub-structure underneath the root folder.
For projects, I created a sub-folder, aptly called “Projects”, which itself contains additional project related sub-folders. To make it easier to find projects that I’m actively working on, I created an “Actively Working” sub-folder. Inside of it is one of the real keys to making the magic of the 17-button mouse work. I will only ever be working on a few active projects. So I number them starting from 04 (we’ll get to why I start there in a moment) to 11. For projects that I’m still somewhat watching but I’m not ready to move over to a “completed” folder that I have, I just rename them to begin with “z.” so that they fall to the bottom of the list.
The Macro Toolbar
You may have guessed by now, but we’re going to be mapping the number pad on the side of the mouse to file emails into these 04-11 folders. Button 4 will look for a folder that begins with “04” and then place the selected item(s) in that folder. The same applies all the way through button 11. There are 3 other options and one special folder that I also have mapped, taking up the rest of the 12 buttons on the pad. All of these actions are mapped into macros that are placed on a toolbar in Outlook.
As you can see, the first two buttons will be used for marking emails either as Unread or Read. I use both of these frequently, so it is very convenient to have them available on the pad. The third button moves to a special folder called “Misc”. You can see it in the screenshot above, just before the Projects folder. Most of the email that I don’t delete will go to the Misc folder because I receive way more miscellaneous email than I do project specific stuff. And in the toughest spot to accidentally hit, number 12 is mapped to delete.
The code itself is fairly simple. I’ve created a GitHub repository of the VBA macro code for moving selected items to folders. You can fetch that and use it. You will need to change the MAIL_STORE to match the name that you see at the top of your folder list. There are really only two functions that do work. The first is the one that will actually move all selected items to a folder.
'// Moves all selected items in the active window to the specified Folder Private Sub MoveSelectionToFolder(f As Folder) Dim win As Outlook.Explorer Dim selObjs() As Object Dim l As Long Set win = Outlook.Application.ActiveWindow '// Make an array of the currently selected items ReDim selObjs(1 To win.Selection.Count) For l = 1 To win.Selection.Count Set selObjs(l) = win.Selection(l) Next l '// Move each item. Debug output so you can see a list of what has moved and where. For l = LBound(selObjs) To UBound(selObjs) Debug.Print CStr(Now()) & " Moving item: " & selObjs(l).EntryID Debug.Print CStr(Now()) & " to: " & f.FolderPath Call selObjs(l).Move(f) Next l End Sub
The array is necessary because as soon as you start actually moving items you run into issues with the remaining selection. So we first take a reference of all the selected items, then we move them all to the specified folder.
The other important function actually looks up our specified project folder by number. This is the important piece of getting from the mouse button to a particular folder to move to. Unless you go with the same naming scheme that I have used, this is also where you would need to modify where it is looking at to find these folders. It does not search your entire directory structure. I have hard-coded it to only look in the “\@\Projects\Actively Working” path.
'// Move all selected items to a subfolder in "Active Projects" by matching the number Public Sub MoveSelectionToActiveProjFolder(folderNum As Integer) Dim activeFolders As Folders Dim f As Folder Dim l As Long Dim numStr As String '// The parent folder for this (customize for how you setup your own folders) Set activeFolders = Application.Session.Stores(MAIL_STORE).GetRootFolder().Folders("@").Folders("Projects").Folders("Actively Working").Folders '// Iterrate each subfolder, compare the left 3 characters for a match. numStr = Format(folderNum, "00") & "." For l = 1 To activeFolders.Count Set f = activeFolders(l) If (Left(f.Name, 3) = numStr) Then Call MoveSelectionToFolder(f) Exit Sub End If Next l '// If we didn't exit then we didn't match a folder. Send a notice. Call MsgBox("No folder is assigned to number " & CStr(folderNum) & ". To assign, rename a folder in the ""Actively Working"" folder to begin with """ & CStr(folderNum) & ". """, vbInformation, "Project Not Assigned To Number") End Sub
Now those functions are great for doing the work, but they’re not good for exposing so that we can make them available for the mouse to invoke in some way. So what we can do about that is write up simple little macro functions that will handle each of our buttons which we need macros for. We actually only need these macros for buttons 3-11. There are already other menu commands for Read and Unread that we can put in the toolbar, and we can just map number 12 to the actual delete key.
'// Move all selected folders to the "Misc" folder. '// This is a public macro that can be placed on an Outlook toolbar Public Sub MoveSelectionToMisc() On Error Resume Next '// Customize the folder path for your needs Call MoveSelectionToFolder(Application.Session.Stores(MAIL_STORE).GetRootFolder().Folders("@").Folders("Misc")) End Sub '// Macros that can be placed on a toolbar and invoked to perform moves to folders Public Sub MoveSelectionToActiveProject4(): Call MoveSelectionToActiveProjFolder(4): End Sub Public Sub MoveSelectionToActiveProject5(): Call MoveSelectionToActiveProjFolder(5): End Sub Public Sub MoveSelectionToActiveProject6(): Call MoveSelectionToActiveProjFolder(6): End Sub Public Sub MoveSelectionToActiveProject7(): Call MoveSelectionToActiveProjFolder(7): End Sub Public Sub MoveSelectionToActiveProject8(): Call MoveSelectionToActiveProjFolder(8): End Sub Public Sub MoveSelectionToActiveProject9(): Call MoveSelectionToActiveProjFolder(9): End Sub Public Sub MoveSelectionToActiveProject10(): Call MoveSelectionToActiveProjFolder(10): End Sub Public Sub MoveSelectionToActiveProject11(): Call MoveSelectionToActiveProjFolder(11): End Sub
Now that we’ve got the code all taken care of, it’s time to create that toolbar. Use the Tools -> Customize menu to create a new tool bar. Go over to the Commands window and drag your macros to the toolbar. You’ll want to right-click on each one and change the name. I use this renaming capability to also assign an accelerator key to each of the keys between 3 and 11. This is done by using the ampersand sign (&) immediately before whatever key you want to be the accelerator key. You invoke the accelerator action by hold ALT and pressing the accelerator key (e.g. ALT 3 will invoke the toolbar button named “&3. Misc”).
Once your toolbar is rigged up, it’s time to finally configure the mouse. The Razer Naga comes with software that allows you to configure profiles for different programs and also default behaviors of each key press on the mouse. I configured just the default for the thumb grid. As you can see in the picture, I have assigned each one to a specific key press. The first two use the existing accelerators for marking emails as read and unread in Outlook. The next 9 all map the ALT + number keys so that they invoke the accelerator keys that were put on the toolbar. The neat thing with this is that the toolbar items will actually flash when I press the key, giving a nice visual indicator that your email is going to the folder that you wanted it to. And the nice thing with this configuration is that it is very simple to do.
At this point, you should be good to go for using your mouse to help you deal with your emails. Just remember that as you get done with projects, you can move them off somewhere else and then create a new folder in it’s place using that same number. No need to change the code or anything. And you’ll also very quickly get used to which buttons map to which folder or action. In no time, you’ll find that it’s just a smooth, natural way of dealing with your email.
Get the source at: https://github.com/bspotswood/outlook-naga-macros