Recording a Macro to Generate Code
|Word Developer Reference|
If you are unsure of which Microsoft Visual Basic method or property to use, you can turn on the macro recorder and manually perform the action. The macro recorder translates your actions into Visual Basic code. After you record your actions, you can modify the code to do exactly what you want. For example, if you do not know what property or method to use to indent a paragraph, do the following:
- On the Developer Ribbon, click Record Macro.
- Change the default macro name to a name of your choice and click OK to start the recorder.
- On the Home menu, click the Increase Indent button.
- On the Developer Ribbon, click Stop Recording.
- On the Developer Ribbon, click Macros.
- Select the macro name that you assigned in Step 2 and click Edit.
View the Visual Basic code to determine the property that corresponds to the left paragraph indent (the LeftIndent property). Position the cursor within
Recorded macros use the Selection object. For example, the following instruction indents the selected paragraphs by one half inch.