How to Bind Word Shortcut to Insert Field With Specific Switch Set
🔍 WiseChecker

How to Bind Word Shortcut to Insert Field With Specific Switch Set

Inserting a Word field with a specific switch, such as a date field that always shows the full weekday name, requires multiple steps every time you use it. Word does not provide a built-in command to insert a custom field with a preset switch directly. This article explains how to create a custom keyboard shortcut that inserts any field with your chosen switch, saving you time and reducing errors.

Key Takeaways: Create a Shortcut for a Custom Field With a Switch

  • File > Options > Customize Ribbon > Customize (Keyboard shortcuts): Open the Customize Keyboard dialog to assign a shortcut to a macro.
  • Alt+F9 to toggle field codes: Use this to verify that your macro inserts the correct field code with the switch.
  • Ctrl+F9 to insert a blank field: Use this inside your macro to build the field code programmatically.

ADVERTISEMENT

Understanding Word Fields and Switches

A Word field is a set of instructions that produces dynamic content, such as the current date, page numbers, or document properties. A switch is a modifier added to a field code that changes its output. For example, the DATE field with the \@ “dddd” switch displays the full weekday name, while \@ “MM/dd/yyyy” shows a numeric date.

Word does not have a native command to insert a field with a specific switch already set. You must insert the field, then edit its code to add the switch. This becomes tedious when you regularly use the same field and switch combination, such as a DATE field with a custom format or an INCLUDETEXT field with a specific bookmark.

The solution is to create a VBA macro that inserts the exact field code you need, then bind that macro to a keyboard shortcut. Once set up, pressing the shortcut inserts the field with your switch instantly.

Prerequisites Before You Start

Before creating the macro, ensure that macros are enabled in Word. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select Enable all macros. This setting is required to run your custom macro. After you finish testing the macro, you can return to this setting and choose Disable all macros with notification for better security.

Also, know the exact field code and switch you want to insert. For this guide, we will use the DATE field with the switch \@ “dddd, MMMM d, yyyy” to produce output like Monday, January 6, 2025. You can replace this with any field code and switch you need.

ADVERTISEMENT

Steps to Create a Macro and Bind a Shortcut

Record the Field Code You Need

Press Alt+F9 to show field codes. Insert a blank field by pressing Ctrl+F9. Inside the brackets, type the field code and switch. For example, type DATE \@ “dddd, MMMM d, yyyy”. Press Alt+F9 again to hide field codes. Select the field and press Shift+F9 to see the result. Verify the output is correct. This confirms the exact text you need to put in the macro.

Open the VBA Editor

  1. Press Alt+F11
    This opens the Visual Basic for Applications editor.
  2. In the Project Explorer, double-click Normal
    If Project Explorer is not visible, press Ctrl+R. Double-click Normal to expand it, then double-click Modules.
  3. Right-click Modules and choose Insert > Module
    A new code window opens. This is where you will paste the macro code.

Write the Macro Code

In the new module, paste the following VBA code:

Sub InsertDateWithSwitch()
    Selection.Fields.Add Range:=Selection.Range, _
        Type:=wdFieldEmpty, _
        Text:="DATE \@ \"dddd, MMMM d, yyyy\"", _
        PreserveFormatting:=False
End Sub

Replace the Text value with your own field code and switch. The backslashes before the quotes inside the string are required to escape them. If your switch uses quotes, you must escape them. For a field without quotes, such as a PAGE field, you can write Text:=”PAGE”.

Save the module by pressing Ctrl+S. Close the VBA editor.

Assign a Keyboard Shortcut to the Macro

  1. Go to File > Options > Customize Ribbon
    At the bottom of the dialog, click Customize next to Keyboard shortcuts.
  2. In the Categories list, select Macros
    The right pane shows the available macros. Look for Normal.NewMacros.InsertDateWithSwitch or the name you used.
  3. Select the macro, then click in Press new shortcut key
    Press the key combination you want, such as Alt+Shift+D. If it is already assigned, Word shows the current assignment below. Choose a combination that is unassigned or that you are willing to reassign.
  4. Click Assign, then Close
    Close all dialogs. Your shortcut is now active.

If the Shortcut Does Not Work as Expected

The Macro Inserts a Field But the Switch Is Missing

Check the Text argument in your macro. Open the VBA editor (Alt+F11) and verify that the string is correct. Common mistakes include missing backslashes before quotes or incorrect spacing. For example, the text must include a space before the switch. The correct format is “DATE \@ \”dddd\”” not “DATE\@\”dddd\””.

The Shortcut Key Is Already Used by Word

In the Customize Keyboard dialog, the box below Press new shortcut key shows if the combination is assigned to another command. If it is, choose a different combination. Common unassigned combinations include Alt+Shift+letter, Ctrl+Shift+letter, or Alt+Ctrl+Shift+letter.

The Macro Does Not Run When I Press the Shortcut

Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Ensure Enable all macros is selected. Also check that the macro is stored in Normal.dotm so it is available in all documents. If you stored it in a document-specific module, the shortcut only works when that document is open.

Macro Method vs Built-In Insert Field Command

Item Custom Macro With Shortcut Built-In Insert Field Command
Speed One keystroke inserts the field with the switch Multiple steps: Insert > Quick Parts > Field, select field, add switch manually
Customization You define any field code and switch in the macro Limited to the switches Word offers in the Field dialog
Learning curve Requires writing a simple VBA macro once No coding needed but repetitive
Portability Works in all documents if stored in Normal.dotm Works in all documents without setup
Error risk Low after the macro is tested High due to manual switch entry

You can now insert a field with a specific switch using a single keyboard shortcut. The macro approach eliminates repetitive manual steps and ensures the switch is always correct. For additional time savings, create separate macros for each field and switch combination you use frequently, such as a field that inserts the file name without the path or a field that shows the total number of pages in a specific format. As an advanced tip, store all your field macros in a single module in Normal.dotm and assign each a unique shortcut key for instant access across all your documents.

ADVERTISEMENT