|
[x]
Link Generator
|
||
|
[x]
Link Generator
|
||
| ID: 1220 |
|
[x]
Attachment Details
|
||
|
[x]
Thank you for voting!
|
||
| Thank you for voting! Helpful votes let the author know what you think about their article. For every 'yes' vote that the article gets, the author receives 50 points! | ||
This is a pretty basic step which you can probably do on your own, but just for the sake of completion, you will want to make a new folder and name it however you like. In this example, I've created a new folder and named it "Archive". If you already have a folder you plan on using, you can skip this.
You're going to be making a simple VBA macro for moving messages to a specified folder. To do this, you need to open up the VBA project for your Outlook (by pressing Alt+F11). When it opens, your window will look similar to the one in the screen shot below. Then, right click your project on the left, and click Insert, Module, as shown:
This is where the hard work has been done for you :)
The code below is designed so that you can make as many different macros as you want where all they do is call the main function with the name of the folder you wish to move selected mail to. The code to copy in is below:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: | Option Explicit
Public Sub Archive()
MoveSelectedItemsToFolder "Archive", False
End Sub
Public Sub ArchiveAndMarkAsRead()
MoveSelectedItemsToFolder "Archive", True
End Sub
Private Sub MoveSelectedItemsToFolder(FolderName As String, MarkAsRead As Boolean)
On Error GoTo ErrorHandler
Dim Namespace As Outlook.Namespace
Set Namespace = Application.GetNamespace("MAPI")
Dim Inbox As Outlook.MAPIFolder
Set Inbox = Namespace.GetDefaultFolder(olFolderInbox)
Dim Folder As Outlook.MAPIFolder
Set Folder = Inbox.Folders(FolderName)
If Folder Is Nothing Then
MsgBox "The '" & FolderName & "' folder doesn't exist!", _
vbOKOnly + vbExclamation, "Invalid Folder"
End If
Dim Message As Object
For Each Message In Application.ActiveExplorer.Selection
If MarkAsRead Then If Message.UnRead Then Message.UnRead = False
Message.Move Folder
Next Message
Exit Sub
ErrorHandler:
MsgBox Error(Err)
End Sub
|
When you've pasted it in, everything should look like this. Remember to replace the highlighted text with the name of your folder. In this example, the folder name is "Archive":
Now you can close down the Microsoft Visual Basic window. You've done the hard part. Next we want to add the macro to the toolbar so that you can use it conveniently. Right click on a blank area of the toolbar as shown, and click "Customize...". This will bring up the Outlook Customize Toolbars dialogue.
You have to find your macro and drag it onto the Toolbar now. Switch to the "Commands" tab in the dialogue, and select "Macros" from the list on the left. You should see "Archive" macro there. The other macro will Archive and mark the email as read in one step. If this is what you would like the button to do, you can choose this macro instead. Select it and drag it to wherever you want it on your toolbar:
You probably don't like the ugly name Outlook has given your button, so go ahead and rename it. To do this, click the "Rearrange Commands" button at the bottom of the dialogue we have open (I know - pretty unintuitive). A new dialogue will open. Click the "Toolbar" option button (instead of "Menu Bar") and find the new button you just created. When you find it, select it and click the "Modify Selection" button. Here, you can rename it to whatever you want. Here's an illustration:
If you want, you can give your button a shortcut by inserting an ampersand (&) in front of the letter you want to be the shortcut. Then when you press Alt+'That Letter', it will trigger the button. Careful, if you chose a letter that is already a shortcut (like A for 'Actions' menu item) then you'll have to press Alt+A+A(again) to cycle through to your button. Here's an example:
Now test it out! Select one or more emails, click the button, and watch them get moved to your archive. Isn't that sharp?
| 11/20/09 09:54 AM, ID: 5810 |
| 11/26/09 01:44 PM, ID: 5982 |
Advertisement
I thought your article was most helpful. However, I'm running into some problems.
I have installed Google Apps Sync for Outlook on a clients computer, and when trying to use the macro on messages within the inbox, they just disappear. When trying to use the macro on messages in other 'folders', it works as per normal. Any clues as to why this is occuring?
Cheers