How to Find Out Which Command Word Executes

You may sometimes need to find the name of the built-in command Word executes when you click an icon or select a command in the Ribbon. For example, you need to know the command name in order to assign a keyboard shortcut to the command. You also need to know the command name if you want a macro to run instead of a built-in command. In order to achieve this, the macro must be named as the command executed by the built-in command. This article explains how to quickly determine the correct command name.

Example

You want to run your own macro when inserting a comment in order to make all new comments appear with predefined content. You can create a macro with any name and assign the macro to a toolbar (Word 2003 and earlier) or to the Quick Access Toolbar (Word 2007, Word 2010, Word 2013 or Word 2016). But if you want the macro to run automatically instead of the built-in command for inserting a comment, you will need to determine the exact name of the command.

What to do

1. Press Ctrl+Alt+[Plus on the numeric keypad].

The cursor changes into a cloverleaf:

Cloverleaf cursor

2. Click the command you want to find information about (in this example Insert > Comment).

Click the command you want to find information about

Note that you can click until you hit a specific command – the cloverleaf cursor changes to an arrow cursor until positioned over a proper target. If the command is in a menu (or on another tab than the active tab in case of Word 2007, Word 2010, Word 2013 or Word 2016), just make selections until you can click the relevant command.

When you click a command, the Customize Keyboard dialog box opens with the selected command displayed as illustrated below.

Customize Keyboard dialog box

In Word 2007, Word 2010, Word 2013 or Word 2016, you may experience that a target you click does not give any result. I have also seen a message saying "Word encountered a problem" when clicking an item in a list of some kind. However, you should be able to find most command names as explained above.

If you enter the "cloverleaf-mode" by mistake, you can press the Esc key to return to normal mode.

If you know Word 2003 or earlier versions of Word, you may notice that the command names are closely related to the menu structure in those versions of Word. For example, commands found in the Format menu start with "Format" (example: "FormatParagraph" is the name of the command that opens the Paragraph dialog box. The command names are retained in Word 2007 and later versions. If you remember the menu structure you may be able to quess a command name.

IMPORTANT if your version of Word is not in English

The command names you see in the Customize Keyboard dialog box are language-specific. If your Word version is in English, the command names are in English too. If your Word version is in Danish, the command names are in Danish too. When assigning shortcuts, this will not cause problems.

If you are going to use a command name to intercept a built-in command, using the English command name will work even if a user of the macro use another language version of Word. But the opposite is not the case. If you create a macro using a command name in another language than Danish that macro will not run instead of the built-in command on that users computer – Word does not recognize the macro name as the name of a built-in command. This means that you should always use the English command names in macros that are to intercept built-in commands if there is any chance/risk that the macro is going to be used on a computer with another language version of Word than the one you are using.

If you need to find a command name in English and if you know the name in another language, you can, for example, find information via Microsoft language resources.

Example

The command that is named "FormatParagraph" in English is named "FormaterAfsnit" in Danish.

A macro named "FormatParagraph" will run instead of the built-in command that opens the Paragraph dialog box no matter the language version of Word – English, Danish or another language.

A macro named "FormaterAfsnit" will only run instead of the built-in command that opens the Paragraph dialog box if the Word version is in Danish.

Macro example – intercept a built-in command

If you insert a comment using the built-in command, the result is a comment that shows your user initials (LF in the example below) plus an index number (1 in the example below):

Comment as it appears using the built-in command

If you copy the macro below and insert it in your Normal.dot / Normal.dotm or in a global template, all comments you insert will instead look like this:

Comment as it appears when using the macro

In the illustrations above, formatting marks are visible in order to show exactly what is included in the comment.

The macro

Sub InsertAnnotation()
    With Selection
        'Stop if selection is not in main story
        If Selection.Range.StoryType <> wdMainTextStory Then
            MsgBox "The selection must be in the main story.", _             vbInformation, "Insert Comment"
            Exit Sub
        End If

        'Insert comment
        .Comments.Add Range:=Selection.Range, _
            Text:=vbCr & "Suggestion: " & vbCr & "Ground: "
    End With

End Sub

Related information

See About VBA Macros and Code Snippets and How to Install a Macro for misc. information that may help you in your work with macros and for information about how to install macros.

Free Trial icon
Word Add-In from DocTools
Did you know that...

DocTools Word Add-Ins
can help you save time in Word

On my website wordaddins.com you will find some of the Word Add-Ins I have developed, ready for use:

Generate complete documents in seconds from re-usable text or graphics - read more...

helps you manage comments in Word fast and easy – review comments, extract comments, etc. - read more...

Makes it easier than ever to work with cross-references in Word documents - read more...

Lets you manage document data efficiently with custom document properties and DocProperty fields - read more...

Lets you extract insertions, deletions and comments in full context and including headings - read more..

Lets you apply or remove any highlight color by the click of a button - read more...

Browse pages, headings, tables, graphic, etc. and find text in Word with a single click - read more...

Browse pages, headings, tables, graphic, etc. and find text in Word with a single click - read more...

Lets you quickly and easily create screen tips in Word with up to 2040 characters - read more...