6/29/11

Setting up Macro in Outlook 2010


Macro is really helpful when you have something that you do constantly over and over again. A macro would be a combination of multiple steps that could all be executed at once with a click of a single button. It is definitely helpful. Isn't it?

Say you have a email and you want to format it to a certain style and then print it and then send it. So, manually you would have to change format first. Then go to print and finally send it. You have 3 steps. So what is macro? With macro using visual basic you could write a small procedure which would have these 3 statements or even more if you like. Hence, the next time you would just run the procedure like a program and all the statements would be execute like a small program. Just imagine you wouldn't have to go through all these steps again.
Anyways, macro is an excellent tool. However, in outlook it is only available as an Advanced option. It is hidden by default. And another thing is you can't "record" macro in outlook as in other product such as excel. For someone that is not familiar with recording, so recording basically means creating a new macro simply by clicking play and then following the steps which you want to be saved. In contrast, in outlook, you don't have this option, hence users would have to have knowledge of programming and write actual programming statements to create macro. Hence, it wouldn't be easy for average users. But still there are many sample codes available for common macros online and you could always copy code and create your own.

Here are the steps in getting Macro enabled in your outlook,
1. select the Options menu.



 2. Now, select the Developer option and select Add to add it the ribbon bar.



3. Now, you should be able to see the "Developer" tab in the ribbon.


4. Under "Developer" tab, you should be able to see the "Macros" option which would take you the editor to create new macros. Also, you would run macros from here.


5. Above, you can see the editor screen where you could write procedure using VB language.




6. Here, you can see that you could run macro by simply selecting it.


Sample Macro :

The purpose of this macro is to run the defined "rule". I have several rules created in outlook and in this procedure I have several statements that would make all those rules to run at once with a single command.

Code:
Sub move_msg_to_resp_folders_using_rule()
    Application.Session.DefaultStore.GetRules("Name_Rule_1").Execute
    Application.Session.DefaultStore.GetRules("
Name_Rule_2").Execute
    Application.Session.DefaultStore.GetRules("
Name_Rule_3").Execute
End Sub

Here, Name_Rule_1 and other are the actual name of the rules. As you see, it is getting executed.

This is just a sample application and you could have macros for anything you like. Just check out the microsoft website for more information regarding the development.

Few books that could be helpful to you.





No comments:

Post a Comment



Again, you can't connect the dots looking forward; you can only connect

them looking backwards. So you have to trust that the dots will somehow connect

in your future. You have to trust in something - your gut, destiny, life, karma,

whatever. This approach has never let me down, and it has made all the

difference in my life.


- Steve Jobs