Several methods exist to create a new empty VBA macro in Microsoft Word. The included steps are based in Word for Mac. While the instructions vary a little between Word for Windows or Mac, the steps in Windows are very similar. Alternatively, see a similar video introduction in Word for Windows on my YouTube channel, but the video covers more than just creating an empty macro.
Thanks for your interest
This content is part of a paid plan.
What is a macro?
Macros are just text files with instructions for Word to follow when the macro is "run." Usually all steps are done automatically by Word, but we have a lot of control over the process through Word's macro language Visual Basic for Applications (VBA).
VBA attempts to describe the individual steps or commands as much like English as possible, but it sometimes needs a little extra information to properly define the various instructions to carry out on your document. Word comes with a dedicated text editor to create and test macros. Our goal in this article is to create a bare macro skeleton that specifies the beginning and ending a macro. We can then add more meaningful steps in between them as needed using the VBA editor.
Create an empty macro in Word
Three methods exist to create a new Word macro. The fastest just uses the status bar button, but we can also use the View menu on the ribbon or just create one manually in the VBA editor.
Click quick record macro button
Click the Record Macro button at the bottom left of the Microsoft Word window.

The Word for Windows icon is a little different, but it still includes the start button circle on the right. This method is convenient in the beginning, but it is a little clumsy once you know how to create your own from scratch.
Enter macro name
Provide a name (step 1 below), decide whether or not you wish to assign a keyboard shortcut (step 2 optional), and click or tap OK (step 3). Older versions of Word, including Word for Windows, may include another option at step 2 beside just a Keyboard assignment for the macro.

Create a custom keyboard shortcut
Many custom macros will be assigned to a keyboard shortcut such as Command+Option+Control+X. If so, click the "Keyboard" button in the new macro dialog (step 2 above) which will open a second dialog.

In this second dialog, click into the edit box (step 1) if necessary and press your desired keyboard combination using modifier keys Control, Command, Option, and/or Shift on Mac or Control, Alt, and/or Shift in Windows along with another main key. Not all combinations will work, but Word will just ignore any it does not recognize.
The description text below the tentative shortcut assignment shows the macro or command the key combination is currently assigned to run. [Unassigned] is usually good because it would otherwise override any existing assignment. Click the Assign button to accept the key combination (step 2). If you make a mistake, you can reset all custom key assignments at the bottom, but it really does "Reset All ..." of them, so be careful.
Then click OK (step 3). If you changed your mind about using a keyboard shortcut, just click OK without setting up a key combination.
In Word for Mac, we can also access the same dialog through the menu options (via Tools → Customize keyboard...) to assign a shortcut to an existing macro at a later time. The related Word for Windows dialog is clumsier to access (via File → Options → Customize Ribbon and click the Customize... button in the last dialog). Just locate the macro in the list and make the assignment. Other articles on this site cover automatically assigning keyboard shortcuts using a macro, but that is beyond the scope of this article.
About the key combination (as text)
If you are not familiar with this expression, Command+Option+Control+X, for a key combination, it means press the Command, Option, Control, and X keys at the same time. However, pressing the X key a moment after the modifier keys is another common way to invoke the shortcut.
Stop recording the empty macro
Immediately click the stop recording button without doing anything. Otherwise, Word will automatically record your actions and add the corresponding auto-generated commands into the new macro.

What if you did something?
If you did anything before stopping the recording, it's not the end of the world. You can just delete the extra steps Word generates when we get to the macro text in the editor below.
Almost as fast method
A similar method uses the ribbon. If you’ve ever recorded a macro before, this is probably how you started. Here is a quick animation:
Accessing the empty VBA macro
Word comes with a dedicated text editor to create and test macros. In VBA, macros are called subroutines which is shortened to “Sub” in the VBA editor. Whichever way you used to create the new empty macro, you can access it by pressing Option+F11 on Mac (or Alt+F11 on Windows) to open the VBA editor. Your empty macro should be waiting on you.

If you already have other macros, they will probably be included above your new empty macro. Any substantive steps would go below the comment but before "End Sub".
Comments
Anything following a single quote character on a given line in the macro will be ignored by VBA when running the macro. We call this a “comment,” and they are color coded in green in the text editor to make them easier to see and differentiate from the commands that VBA does run. Comments are only intended for human eyes, and they will be more important as your macros become more complex (and they will).
Easier but more technical method
This method is little more technical but not too bad if you're nervous about that sort of thing.
Once you get used to the VBA editor, the easiest way to create a new macro is to just skip the recording step entirely and start by pressing Option+F11 on Mac (or Alt+F11 on Windows) to open the VBA editor. In the editor window below or between any existing macros, literally just start typing the macro:
In fact, the VBA editor will probably try to help you by automatically including "End Sub" at the end once it detects you are creating a new macro.
Macro names can't have any spaces, and the only punctuation allowed is an underscore. We also cover how to add or update keyboard shortcuts for an existing macro. We’ll dig into more macro details later, but you now have a new empty macro you can begin customizing for any project.
In other articles, we'll add some useful steps manually to save time recording and then editing the resulting Word macro. At this point in your VBA exploration, this approach may sound preposterous, but many Word VBA commands are quite easy to understand and include in your macros.