How to Create a Word Macro to the End of a Document
- 1). Open Microsoft Word. Click "File" and select "Options. "
- 2). Click "Customize "Ribbon" and put a check mark next to "Developer.
- 3). Click "OK." Word will add the "Developer" tab to the ribbon at the top of the screen.
- 1). Open Word and click the "Office" button at the top of the screen.
- 2). Select "Word Options" and then select "Popular."
- 3). Select "Show Developer Tab in the Ribbon" and click "OK." Word will add the "Developer" tab to the ribbon.
- 1). Press "ALT+F8." The "Macro" window will open. Type a name for the macro in the "Macro Name" text box. Use a descriptive name that has no spaces. For example, you might name it "EndOfDocument."
- 2). Click "Create." The VBA editor will open and display a blank subroutine. A subroutine is a block of code that performs a task. In this instance, this subroutine will execute the instructions for the macro that you created. The subroutine skeleton will look similar like this:
Sub xyz()
End Sub
The name of the sub will not be "xyz." It will instead contain the macro name that you entered in the "Macro Name" text box. - 3). Paste the following code after the "Sub" statement:
Selection.EndKey Unit:=wdStory, Extend:=wdMove - 4). Click the "X" button at the top right corner of the VBA editor window to close the window and return to Word's main screen.
- 5). Open a document that has several pages and position the mouse cursor on the first line.
- 6). Press "ALT+F8" to open the "Macro" window. Highlight the macro that you created and click "Run." It will execute and move to the end of the document.