All Local variables as Statics

Figure 9.5 - Use the Add Procedure dialog box to create a Sub procedure for an Outlook macro.

Once you have created your macro procedure and debugged it, you'll want to customize either an Explorer or Inspector toolbar so that you can run the macro with a mouse click. Be aware that you must lower your Macro Security settings to Low or Medium in order to run any VBA macro code. In order to test the LaunchWordMail macro, you can simply insert the cursor into the LaunchWordMail Sub procedure in the Code window and select Run Sub/UserForm on the Run menu on the Visual Basic Editor toolbar. To continue with the LaunchWordMail macro example, use the following steps to create a toolbar button to run the macro:

To add an Outlook Macro to the Standard toolbar for the Explorer

1. In the Outlook Explorer, select the Customize command on the Tools menu.

2. Select Macros in the Categories drop-down list box on the Commands page.

3. Drag the LaunchWordMail macro to the position on the Standard toolbar where you want the toolbar command button to appear.

4. Right-click the Projectl .LaunchWordMail toolbar button, and set its properties. For example, you might want to rename the button to WordMail.

If you have created a number of Outlook macros, adding macros to the toolbar can be impractical and can pose a security risk. You can also use the Macros dialog box to run an Outlook macro, provided that your Macro Security settings are either Low or Medium.

To change your Macro Security settings

1. Point to Macro on the Tools menu, and select Security on the Macro pop-up submenu.

2. In the Security dialog box, change the Security Level to Low or Medium. Changing the Macro Security setting does not alter the built-in attachment and object model guard security for Outlook 2002. These security protections remain in place no matter how you set Macro security.

To run an Outlook Macro using the Macros dialog box

1. Press Alt+F8 in an Outlook Explorer or Inspector window.

2. Double-click the macro name in the Macros dialog box.

Was this article helpful?

0 0

Post a comment