Managing Macros

Word, Excel, PowerPoint, Outlook, Publisher, and FrontPage include built-in tools for creating and deleting macros. In all six applications:

  1. Choose Tools, Macro, Macros, and you'll see the Macros dialog box (see Figure 39.2).

    Figure 39.2. If more than one document, template, workbook, or presentation is open, you can narrow down the list of macros by making a choice in the Macros In box.

  2. To create a new, empty macro, type a name for the new macro, choose a location for it in the Macros In box, and click Create. VBA creates a new subroutine with the given name, and puts you in the VBA Editor (discussed in the next section), ready to start typing your macro.

    Word places newly created macros in a module called NewMacros. Excel and PowerPoint put them in modules called Module1, Module2, and so on. If you want to place your new macro in a specific module, use the VBA Editor.

Tip from

If you want to easily copy and move individual macros in Word, you'll want to move them out of the NewMacros module and give them their own module.


  1. To delete a macro, click the macro's name and click Delete.

Of all the Office applications, only Word provides any tools for copying and moving macros—and even then, you have to move or copy an entire module full of macros at a time. To copy a VBA/Word module or UserForm (custom dialog box) from one document or template to another, or to delete or rename a module or UserForm:

  1. Choose Tools, Macro, Macros, and click the Organizer button. The Word Organizer opens (see Figure 39.3).

    Figure 39.3. The Word Organizer can copy or move modules or UserForms—so-called "macro project items"—but not individual macros.

  2. Click the Macro Project Items tab. You'll see a list of all modules and UserForms in the current document (on the left side of the dialog box) and in the Normal "global" template (on the right side of the dialog box).

→ For detailed information on how to work with Normal.dot, see "Customizing the Normal Document Template".

  1. If necessary, select different "from" and "to" documents or templates from the Macro Project Items Available In boxes. (Note that you can copy in either direction, left-to-right, or right-to-left.) If the document or template isn't available in these lists, click Close File, and then click Open File and select the correct document or template.

  2. Click once to select the module or UserForm you want to copy, delete, or rename, and then click the appropriate button to copy, delete, or rename it (the arrows on the Copy button show you which file you'll copy from and to). Note that you cannot move a module in a single action: You must copy it, and then delete it.

Modules often contain more than one macro, and the Word Organizer won't tell you the names of the macros in a module. Be careful that you don't copy or delete the wrong macros, or rename the wrong module.

Caution

If you use macros that are confidential or proprietary, be sure you know what macros are in a module before you copy and distribute it. Because the individual macro names never appear in the Organizer, it's easier to make a mistake than you might think.


To copy, move, delete, or rename an individual macro in Word, Excel, PowerPoint, Outlook, Publisher, or FrontPage, you have to use the Visual Basic Editor, as described in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.10