Modifying a Word Command

You can modify most 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, 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 FileSave shortcut key combination.

This example takes you through the steps needed to modify the FileSave command.

  1. On the Tools menu, point to Macro, and then click Macros.

  2. In the Macros In box, select Word Commands.

  3. In the Macro Name box, select FileSave.

  4. 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 (the FileSave command will be modified for all documents).

  5. Click the Create button.

The FileSave macro appears as shown below.

Sub FileSave()
'
' FileSave Macro
' Saves the active document or template
'
    ActiveDocument.Save

End Sub

You can add additional instructions or remove the existing ActiveDocument.Save instruction. Now every time the FileSave command runs, your FileSave macro runs instead of the word command. To restore the original FileSave functionality, you need to rename or delete your FileSave macro.

Note   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.