Modifying a Word Command
|Word Developer Reference|
You can modify most Microsoft Word commands by turning them into macros. For example, you can modify the Open command on the File menu so that instead of displaying a list of Word document files (files ending with the .doc file name extension), Word displays every file in the current folder.
To display the list of built-in Word commands in the Macro dialog box (Alt-F8), you select Word Commands in the Macros In box. Every menu command and every command available on a toolbar or through shortcut keys is listed. Menu commands begin with the menu name associated with the command. For example, the Save command on the File menu is listed as FileSave.
You can replace a Word command with a macro by giving a macro the same name as a Word command. For example, if you create a macro named "FileSave," Word runs the macro when you choose Save from the File menu, click the Save toolbar button, or press the Ctrl-S shortcut key combination.
This example takes you through the steps needed to modify the FileSave command.
- Press Alt-F8.
- In the Macros in box, select Word commands.
- In the Macro name box, select "FileSave".
- In the Macros in box, select a template or document location to store the macro. For example, select "Normal.dot (Global Template)" to create a global macro (this modifies the FileSave command for all documents that use the normal tempate).
- Click Create.
The FileSave macro appears as shown below.
You can add additional instructions or remove the existing
You can also replace a Word command by creating a code module named after a Word command (for example, FileSave) with a subroutine named Main.