Creating Custom Toolbar Buttons

Now that you know how to create VBA code to work with Outlook, you're probably wondering whether you have to enter the VBA editor every time you want to run this code. The answer is no. There are two main ways you can run a VBA procedure from Outlook without entering the VBA editor. You can call a macro directly from the Macros menu, or you can create a custom toolbar button to accomplish the same task.

NOTE

Other Office products, such as Word and Excel, have the capability to record macros. All a user has to do is start recording, and then go through the steps she wants to record and stop recording. When the user is done, she has the macro built, complete with code that can then be modified for further tweaking. Outlook does not have this feature. A macro in Outlook is really just a code procedure you must write yourself.


To view a list of all macros in Outlook, select Tools, Macro, Macros to display Figure 33.8.

Figure 33.8. Select a macro to run or view the code behind any macro.

graphics/33fig08.gif

From this list, you can select any macro and click Run to execute the code in the macro. You can also edit the macro's code and launch the VBA editor by clicking the Edit button. If you want to step through the code to debug a macro, select Step Into.

This isn't a very elegant way to run a macro, and if you routinely run the same macro often, consider creating a toolbar button for the macro. To create a toolbar button to run a macro, use the following steps:

  1. Right-click anywhere on a toolbar and select Customize to display the Customize dialog box.

  2. Select Macros from the Categories list box to display Figure 33.9.

    Figure 33.9. You can create a toolbar button for any macro in Outlook.

    graphics/33fig09.gif

  3. The Commands list box contains a list of all macros in your project. Choose the macro you're interested in and drag the button to your toolbar.

  4. A button will be added with the project name and procedure name of your macro, as shown in Figure 33.10. To change its name, right-click on the new toolbar button and change the button's name. This changes the caption of the button.

    Figure 33.10. Your new toolbar button does not look very useful.

    graphics/33fig10.gif

  5. You can also change the button image or style by right-clicking on the new toolbar button and selecting a new style or a new button image.

  6. When you're done customizing your toolbar button, click Close. Your new toolbar button might look similar to Figure 33.11.

    Figure 33.11. Change the image and caption for your button to something more relevant.

    graphics/33fig11.jpg

You can use these steps to create toolbar buttons for all of your Outlook macros.



Special Edition Using Microsoft Office Outlook 2003
Special Edition Using Microsoft Office Outlook 2003
ISBN: 0789729563
EAN: 2147483647
Year: 2003
Pages: 426

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net