Attaching a Macro to a Toolbar


As you build macros, you might not remember the macro names or even their shortcut names. You can use Tools, Macro, Run to choose the macros, but this method requires you to continually pull down the menu and scroll through the list of names in the Macro dialog box. A more efficient way to run a macro is to assign it to a button on a toolbar. Assigning a macro to a button makes the macro run whenever you click the button with your mouse. Attaching macros to a toolbar is a quick way to organize your macros so that any user can easily run them.

The following steps show you how to attach a macro to the Standard toolbar for the Detail sheet.

  1. In the Detail sheet, choose Tools, Customize. The Customize dialog box appears.

  2. Click the Toolbars tab. The Standard toolbar check box should have a checkmark in it. The checkmark means that the Standard toolbar is currently displayed, and you can make changes to it. You're going to attach the macro to this toolbar.

  3. If the button you want to run the macro from is not on a toolbar, click the Commands tab and then click Macros in the Categories list.

  4. In the Commands list, you should see the Custom Button with a smiley face next to it, as shown in Figure 49.6. Drag the Custom button onto the Standard toolbar, placing the button between the Zoom box and the Help button at the far right end of the toolbar. You should see a thick border surrounding the Custom button with the yellow smiley face on it.

    Figure 49.6. The Macros category and Custom Button command.

    graphics/49fig06.gif

  5. Right-click the Custom toolbar button and choose Assign Macro. The Assign Macro dialog box opens, as shown in Figure 49.7.

    Figure 49.7. The Assign Macro dialog box.

    graphics/49fig07.gif

  6. Click the Font_change macro name. This step enters the name of the macro in the Macro Name box.

  7. Click OK. Excel attaches the macro to the Custom button on the Standard toolbar. Click the Close button to close the Customize dialog box. Now you want to test the new macro button on the toolbar.

  8. Select cell A4. Click the Custom Button button on the Standard toolbar. Bingo! Excel changes the font and font size for the data you selected on the worksheet. You should see the 28-point Arial font.



Sams Teach Yourself Office Productivity All in One
Sams Teach Yourself Office Productivity All in One (Sams Teach Yourself All in One)
ISBN: 0672325349
EAN: 2147483647
Year: 2003
Pages: 474
Authors: Greg Perry

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