Recording a Macro

Let's start with a simple example. Imagine that you want to insert a standard mailing address for your company into a variety of Word documents. Rather than type the text from scratch each time, you decide to create a macro that inserts the text automatically when you press the key combination Alt+A. Complete the following steps to record the macro using the Record New Macro command on the Macro submenu of the Tools menu.

  1. Display the Word, Excel, or PowerPoint document in which you want to record the macro.

    If you want to follow these instructions exactly, open a blank Word document now.

  2. From the Tools menu, choose Macro, and choose Record New Macro from the Macro submenu to open the Record Macro dialog box. Your screen should look like the following:

    Notice the Store Macro In drop-down list box, which prompts you for a place to save the macro. In Word, you can store your macro in the normal document template (Normal.dot), which will allow you to run the macro in all Word documents, or you can store your macro in the current document by selecting the document name in the Store Macro In drop-down list box. In Excel, you can store the macro in the Personal Macro Workbook (so it's available in all workbooks), or you can store it in the current workbook. In PowerPoint, you can save macros in any open presentation.

  3. In the Macro Name text box, type InsertAddress, the name of your macro.
  4. Click the Keyboard button in the Record Macro dialog box to display the Customize Keyboard dialog box, where you can specify the shortcut key that will run your macro. (In Excel and PowerPoint, you just specify the shortcut key in the Record Macro dialog box.)

    TIP
    In Word, you can also create a toolbar button or menu command for the macro at this time. To do so, click the Toolbars button in the Record Macro dialog box, and specify a custom menu command or toolbar button that will run the macro.

  5. Press Alt+A to assign the shortcut key Alt+A to your macro, and then verify that the Save Changes In drop-down list box is set to Normal. Your dialog box should look similar to the following:

    click to view at full size.

  6. In the Customize Keyboard dialog box, click Assign, and then click Close to accept your keyboard shortcut and start recording the macro. Office displays the Stop Recording toolbar and changes the mouse pointer to a recording icon. From this point on, any key you press or any command that you execute in Word will be taped by the macro recorder.

    TIP
    What Are My Recording Options?

    The Stop Recording toolbar contains two useful toolbar buttons, Stop and Pause/Resume Recording. When you're finished recording your macro, click the Stop Recording button, and Word will stop saving your commands and close the macro. If you want to pause the recording temporarily, click the Pause Recording button, modify your document as needed, and then click Resume Recording when you're ready to continue.

  7. Type the following address (or one of your own) in the active Word document, and then press Enter:

    Outdoor Clothing Supply  1219 Hill Garden Drive  San Francisco, CA 94555  (415) 555-5555 

  8. Click Stop Recording to end your macro.

That's all there is to it! Now that you have recorded your first macro, run it in your Word document to verify that it displays the address as you specified.



Running Microsoft Office 2000 Small Business
Running Microsoft Office 2000
ISBN: 1572319585
EAN: 2147483647
Year: 2005
Pages: 228

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