What Are Macros in a Word Document
Word macros are one-click wonders that let you program complex procedures to launch at your bidding. Here are a few examples to get you started. One creates your company letterhead; the second one inserts pre-formatted tables; and the third one defines and designs custom book formats.
NOTE: You'll see some instructions with strings of keystrokes that are macro instructions for repositioning your cursor. Be sure to copy them exactly as written.
Set up, define, and record macros
Step 1: Set up the macro
A. Select the View tab, then click Macros > Record Macro.
B. In the Record Macro dialog box, enter a macro name and description. Follow these rules for the name:
- Macro names must begin with a letter and use either letters or numerals. You cannot use spaces, non-alphanumeric characters, or periods.
- Macro names can be 80 characters maximum
- Macro names cannot conflict with the program's reserved commands or keywords such as Print, Save, Copy, Paste.
- Descriptions are just notes that summarize the macro's function.
C. For the Store Macro In field, choose All Documents to run this macro in all of your Word documents, or select the current document (displayed by filename) to use this macro in the current document only. Click OK.
D. Next, in the Assign Macro To panel, click Button or Keyboard (shortcut) for the method used to access and run the macro.
Note: Most of the shortcut keys are already used by the system. Even though you can overwrite many of these shortcuts, it's much easier to attach your macro to a button.
Step 2: Add a macro button to the Quick Access Toolbar
A. ClickButtonand the Word Options/Customize Quick Access Toolbar screen opens. On that screen, locate your macro, select/highlight it, then click Add. Word copies the macro from the left Macros panel to the right Quick Access Toolbar panel.
B. Click Modify, choose an icon to represent your macro button, then click OK.
C. When finished, click OK again to exit.
Step 3: Record the macro
Enter the keystrokes you want the macro to record. (See 'A' below.)
Step 4: Stop recording
When finished, select the View tab again, then click Stop Recording. (See 'B' below.)
Note: Notice that your customized macro button appears on the Quick Access Toolbar. To run the macro again, just click this button.
Three quick and easy macros
Macro 1: Company Letterhead
Most companies have traded printed letterhead for digital. Take a little time once to record this macro, and you'll be able to drop your letterhead onto a document in one easy second.
Repeat steps 1 and 2 above. Name the macro (for this example) BranchesLetterhead. Then, for Step 3 (macro is now running), follow these macro instructions:
A. From the Insert tab, select Pictures. Navigate to the folder that contains your company's logo, select that image, and click Insert.
B. In the Layout Options dialog, select one of the text wrapping options, then close the dialog. Press the Esc key to deselect the graphic, then press the End key once, and the Tab key once.
C. Enter the company name: Branches, Inc
. Highlight the name. Click the drop-down list in the Font group; choose a typeface and font size. Press the End key once, then press the Enter key three times. Next, press the Up arrow twice, then press Shift + Down, Down (press and hold the Shift key while simultaneously pressing the down-arrow key twice).
D. Select a typeface (for this example, I'm choosing something sans-serif such as Arial or Helvetica), select a size (11-point in this example), then press the Home key once and the Tab key twice.
E. Enter the address information, then press the Enter key three times.
F. From the main menu, clickInsert > Text, then click the Insert Date and Time button. Choose a date format from the Date and Time dialog, check the Update Automatically box, then click OK.
G. Highlight and change the Date and Time font to your company's standard document typeface.
H. Last, highlight the letter 'B' in Branches and increase the font size to 60.
I. From step 4 above, select the View tab again, and click Stop Recording.
Now, anytime you need letterhead, just click that BranchesLetterhead macro button on the Quick Access Toolbar.
Macro 2: Insert pre-designed tables
My friend Carrie created a weekly report that included a table with specific measurements, columns, rows, and headers. She used to copy and paste a table template she created into each new document, but it was always inconsistent and distorted. A table macro was a better solution.
Repeat steps 1 and 2 above. Name the macro (for this example, CorpRptTable). Then, for Step 3 (macro is now running), follow these macro instructions:
A. From the Insert tab, click Table.
B. In the Insert Table dialog, slide your cursor horizontally across the grid to select the number of columns needed, then slide down to select the rows. When the grid is the correct size, click the mouse.
C. Enter the following headers across the top row: Contributor, Occupation, Location, Project, and Donation.
D. With the cursor still positioned at the end of the word Donation in column 5, row 1: press and hold the Ctrl and Shift keys, then press the Left arrow key five times.
E. With the first row highlighted, go to the Home tab and clickParagraph group. Click the icon for center-justified text, then, in the Fonts group, click Bold. Click the Left arrow cursor key once to reposition the cursor in cell A1.
Note: When your cursor is anywhere inside the table, the Ribbon displays a new tab-set called Table Tools Design and Table Tools Layout.
F. With the cursor still in A1, select Table Tools > Layout. In the Cell Size group, click the Table Column Width button and click the arrows to adjust the column width up or down. Set the first column to 1.2 inches. Press the Tab key once, then Left arrow to reposition the cursor in the next column.
Note: If the column header is highlighted, the new column width affects that single row only.
G. With the cursor in the second column before the O in Occupation, go to the Table Tools and click Layout > Cell Size group, and set Table Column Width > 1.2 inches.
H. Adjust the remaining columns to these settings: Location 1.7 inches, Project 1.5 inches, and Donations 1.0 inches.
I Press Ctrl+End to reposition your cursor just outside and below the table, then type: Figure 1
.
J. From step 4 above, select the View tab again, and click Stop Recording.
Macro 3: Create custom book formats
If you create in-house publications, create a macro that sets up a custom format for each. In fact, you could just create one format, then edit that one and resave it to accommodate the individual formats.
Repeat steps 1 and 2 above. Name the macro (for this example) Book8x5Format. Then, for Step 3 (macro is now running), follow these macro instructions:
A. From the Page Layout tab, click Page Setup > Size.
B. Select More Paper Sizes from the drop-down menu.
C. In the Page Setup dialog, select the Paper tab, clickPaper Size, then choose Custom from the drop-down list.
D. Enter a width size of 5.5 inches and a height size of 8.5 inches and click OK.
E. Again, from the Page Layout tab's Page Setup group, click the Margin button.
F. Select Custom Margins from the drop-down list.
G. In the Page Setup dialog, choose the Margins tab.
Note: You must adjust the Pages settings first, selecting Multiple Pages, because this setting alters the margin fields.
H. From Pages > Multiple Pages, select Normal from the drop-down list. For Sheets per Booklet, select All.
I. Enter margins: Top = 1, Bottom = 1, Left = .5, Right = .5, Gutter = .3, and Gutter Position = Left.
J. For Orientation, choose Portrait, then click OK.
Note: The image in the Preview pane shows this layout with margins and gutters.
K. Next, select Paragraph under the Page Layout tab. Click the Indents and Spacing tab.
L. In the General panel, select Alignment = Justified; Outline Level = Body Text.
M. In the Indentation panel, select Left = 0; Right = 0; Special = First Line; By = .25.
N. In the Spacing panel, select Before = 0; After = 0; Line Spacing = Multiple; At = 1.25. And click OK.
O. Enter a paragraph or so of generic text. Right-click and choose Styles from the popup context menu. In the Styles dialog, select your company's stylesheet (CorpStyle) from the list.
NOTE: If your company doesn't have a stylesheet, select Normal. Feel free to read our how-to on creating stylesheets after you finish this macro.
P. Next, select the Insert tab, and go to the Header & Footer group. Click the Header button and choose a style from the list, then enter the header text.
Note: Notice the Header & Footer Design menu appears.
Q. In the Options group, check the boxes for Different Odd & Even Pages. Right-click for the context menu, select paragraph, and choose Alignment: Right (for the odd page header). Next, scroll down to the Footer section: Right-click, select Page Number > Bottom of Page > Plain Number 3 (the right-justified placement).
R. Insert a page break, then repeat steps P and Q above to add headers and footers to the even numbered pages.
S. From step 4 above,select the View tab again, and click Stop Recording.
What Are Macros in a Word Document
Source: https://www.pcworld.com/article/422689/word-macros-three-examples-to-automate-your-documents.html