Lesson 22 Macros THE M PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. I C R O S O F WORD 2007 T ® 2 Objectives • Create a macro. • Run a macro. • Edit a macro. • Copy, rename, and delete macros. • Customize the Quick Access Toolbar. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 3 Macros • Created to perform repetitive tasks quickly. • Include command sequences and keystrokes. • Save a sequence of tasks as a single command. • Include Ribbon commands, formatting options, keystrokes, and dialog box selections. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 4 Create Macros • Store macros in a document or in a template. • Be default, Word stores macros in the Normal template. • Save special-purpose macros in a specialpurpose template. • Plan the steps you want the macro to perform. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 5 Create Macros • Display the Developer tab. • Click the Record Macro button. • Name the macro, but do not include spaces. – Macro names must begin with an alphabetic character. • Determine where the macro will be stored. • Key a brief description. • Click the Keyboard icon and assign a keyboard shortcut to the macro. – Verify the save location for the macro keyboard shortcut. Click Close. • When the recording pointer appears, every action taken with the mouse or the keyboard is recorded. • Do not use the macro pointer to select text or move the insertion point. Click the Stop Recording button when finished. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Record Macro Dialog Box THE PROFESSIONAL APPROACH SERIES 6 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 7 Customize Keyboard Dialog Box THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 8 Set Macro Security • Macro settings located in the Trust Center. • To view or change macro security settings: – Click the Macro Security button on the Developer tab or open the Word Options dialog box. – Click Trust Center. – Click Trust Center Settings. • Verify that the selected setting is Disable all macros with notification. • Click OK. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Trust Center Dialog Box THE PROFESSIONAL APPROACH SERIES 9 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 10 Run a Macro • Open the template or document. • Locate the security warning below the Ribbon. • Click the Options button to open the Microsoft Office Security Options dialog box. • Click Enable this content. • Click OK. • Click the Developer tab. • Click the Macros button. • Verify the setting for the Macros in drop-down list box. • Select a macro. • Click Run. – Run a macro by pressing the keyboard shortcut. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 11 Microsoft Office Security Options THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 12 Edit a Macro • Recorded macros create a VBA program. • Use the Visual Basic Editor to edit macros. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 13 Edit a Macro • Click the Macros button. – The keyboard shortcut to open the Macros dialog box is [Alt]+[F8]. • Verify the setting for the Macros in text box. • Click the template to edit. • Click Edit and the Microsoft Visual Basic Editor window opens. • Edit the macro and click the Save button. • Click File and click Close and Return to Microsoft Word. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Edit a Macro THE PROFESSIONAL APPROACH SERIES 14 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Macro after Editing THE PROFESSIONAL APPROACH SERIES 15 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 16 Copy Macros • Macros are stored in a module. • Modules are attached to Word documents or templates. • All recorded macros are stored in a module named “NewMacros.” • To copy macros from one template to another, copy the NewMacros module. – All macros stored in the module are copied to the template. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 17 Copy Macros • Open the Macros dialog box. • Click the Organizer button. • Click the Macro Project Items tab. – The left side of the dialog box lists modules in the current template. – Click Close File on the right side of the dialog box. – Click Open File on the right side of the dialog box, and locate the folder and template file. – Click Open. The NewMacros module appears on the right. • Select NewMacros. • Click Copy. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Organizer THE PROFESSIONAL APPROACH SERIES 18 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 19 Copy an Individual Macro • Open the Macros dialog box. • Select the macro name to be copied. • Click Edit to open the Visual Basic Editor. • Select the macro text beginning with Sub ( ) and ending with End Sub. • Click the Copy button on the Visual Basic toolbar. • Scroll to the bottom of the code window. • Position the insertion point on a blank line. • Click the Paste button. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Copy an Individual Macro THE PROFESSIONAL APPROACH SERIES 20 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 21 Rename a Macro • Rename the copied macro by editing the text after the word “Sub” on the first line of the macro. • Edit comment lines. • Edit other code lines. • Save the changes and return to Word. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Renamed Macro THE PROFESSIONAL APPROACH SERIES 22 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 23 Delete a Macro • Open the Macro dialog box. • Select the macro. • Click [Delete] and click Yes. • Click Close. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 24 Assign a Keyboard Shortcut • Open the Word Options dialog box. • Click Customize in the left pane. • Click the Customize button to the right of Keyboard shortcuts to open the Customize Keyboard dialog box. • Locate the Categories list and scroll to the bottom of the list. • Click Macros. • Verify the setting for the Save changes in drop-down list box. • Locate the Macros list and click the macro. • Key the keyboard shortcut in the Press new shortcut key text box. • Click Assign. • Click OK. • Click Close. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 25 Customize the Quick Access Toolbar • Three ways to add a command to the Quick Access Toolbar. – Click the Customize Quick Access Toolbar button. – Use the Word Options dialog box. – Use the shortcut menu. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 26 Quick Access Toolbar Command List THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Word Options Dialog Box THE PROFESSIONAL APPROACH SERIES 27 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. Shortcut Menu THE PROFESSIONAL APPROACH SERIES 28 © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 29 Move the Quick Access Toolbar • Default location is beside the Microsoft Office Button. • Click the Customize Quick Access Toolbar. • Click Show Below the Ribbon. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 30 Assign a Macro to the Quick Access Toolbar • Open the Word Options dialog box. • Click Customize in the left pane. • Click the down arrow for the Choose commands from drop-down list box. • Select Macros. • Click the down arrow for the Customize Quick Access Toolbar and select an option. – For all documents (default) – For document • Select the macro and click Add. • Click OK. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 31 Reset the Quick Access Toolbar • Open the Word Options dialog box. • Click Customize in the left pane. • Click the Reset button. • Click Yes to restore the Quick Access Toolbar. • Click OK. THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 32 Lesson 22 Summary • A Word macro enables you to quickly perform repetitive tasks involving command sequences and keystrokes. With a macro, you can save a sequence of tasks as a single command • When you create macros, you store them in either a document or a template. By default, Word stores macros in the Normal template, but it is best to store specialpurpose macros in a special-purpose template • Before beginning a macro recording, plan the steps you want the macro to perform, choose a name for it, and decide where it will be stored • When you see the recording pointer, every action you take with the mouse or the keyboard is being recorded in your macro THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 33 Lesson 22 Summary • You can assign a macro to a button, the Quick Access Toolbar, or to a keyboard shortcut key, which you can then use to run the macro. You can also run a macro from the Macros dialog box • When you record a Word macro, a computer program is created that uses Visual Basic for Applications. You can change the macro by carefully editing the Visual Basic code • You can use the Macros dialog box to edit, rename, or delete macros • You use the Organizer to copy macros from one document or template to another • You can customize the Quick Access Toolbar by adding and deleting commands THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved.