Macros in Microsoft Office programs save you time by automating common actions. Make sure you back up your macros in case you need to transfer them or want to share them.
If you perform the same sets of actions often in Microsoft Office programs, you can save yourself time with macros.
Macros allow you to record multiple actions and then quickly execute those actions by clicking a button or pressing a keyboard shortcut. Word and Excel allow you to record actions into macros, but Outlook and PowerPoint do not. You must manually create macros by writing the code yourself or copying or importing code from somewhere else.
If you’ve recorded macros in Word or Excel or manually created macros in Outlook or PowerPoint, and you need to move them to another computer, you can save the macros and then restore them. Saving your macros also allows you to share them with others and gives you a backup in case something drastic happens.
Save Macros by Backing Up the Normal.dotm Template (Word Only)
Macros are generally stored in the Normal.dotm template for Word. But the Normal.dotm template also contains many other customizations like styles and autocorrect entries. So, if you’re saving your macros to share them with others, you may want to use a different method, which we cover after this section.
This option is really only useful for macros in Word. Excel, Outlook, and PowerPoint deal with macros differently. The best options for saving macros in Excel, Outlook, or PowerPoint are one of the other two methods discussed next.
If you’re saving macros as a backup for yourself, you can copy the Normal.dotm template file to an external or network drive.
The Normal.dotm template file is normally found in the following folder, replacing “[user name]” with your Windows user name:
You can also search for template file if it’s not in the above folder.
Save Macros by Exporting Them to a .bas File
If you want to share your Word macros with others or import them into Word on another computer without affecting the Normal.dotm template, you can save your macros to a .bas file that contains just the macros and nothing else. This method is also recommended for saving macros in Excel, Outlook, and PowerPoint.
In all four Office programs, you can view your macros using the Macros button in the Code section of the Developer tab (which you may need to enable). Or, in Word, you can view your macros using the View Macros option on the Macros button in the Macros section of the View tab.
To access the code for the macros listed on the Macros dialog box, click Edit.
The Microsoft Visual Basic for Applications (VBA) editor opens. You can also press Alt + F11 to open the VBA editor.
In the Project pane on the left, click the plus sign to expand the Normal project in Word, the VBAProject in Excel or PowerPoint, or a numbered Project folder like Project1 in Outlook. Then, expand Modules in the same way and double-click NewMacros, or a numbered module, like Module1.
The name of the code module containing your macros might be different, and you may have multiple modules also. We’re going to use NewMacros here since that is what our code module is called in Word.
All the macros you recorded are listed in the Code window to the right. You can also manually write your own macros in this window.
In the VBA editor, go to File > Export File.
Go to the folder where you want to save the macros. Then, enter a name for the file in the File name box, making sure you keep the .bas extension.
You can open the .bas file in any text editor like Notepad and edit them.
Macros start with Sub and end with End Sub. The name of the macro immediately follows Sub. For example, the name of one of our macros is ArticleSetup. Comments in macros start with an apostrophe.
Save Macros by Copying Them to a Word File
If you prefer, you can also store your macros from Word, Excel, Outlook, or PowerPoint in a Word file.
Open Word and create a new file to store the macros in. Then, press Alt + F11 to open the VBA editor. Or, open Excel, Outlook, or PowerPoint and then press Alt + F11.
In the Project pane on the left, double-click the module name, like NewMacros, under Normal > Modules (or VBAProject > Modules or Project1 > Modules).
Select all the text in the Code window and press Ctrl + C to copy it.
Go to File > Close and Return to Microsoft Word (or Outlook, Excel, or PowerPoint).
Go back to Word and press Ctrl + V to paste the macros into the Word document and then save the document.
Restore Macros Stored in the Normal.dotm Template (Word Only)
If you saved your macros by backing up the Normal.dotm template file, copy the template file back to the following folder, replacing “[user name]” with your Windows user name.
You should be asked if you want to replace the default Normal.dotm file. If not, the template file is probably in a different location. Use Windows Search to find the Normal.dotm template file and copy your backed up template file there.
Remember that the Normal.dotm template in Word also contains many other customizations like styles and autocorrect entries. So, if you’ve already customized the Normal.dotm template on the PC you’re transferring the macros to, you should save the macros using one of the other two methods we describe above.
Restore Macros from a .bas File
To restore your macros from a .bas file, open Word, Excel, Outlook, or PowerPoint and press Alt + F11 to open the VBA editor.
In Word, select Normal in the Project pane on the left in Word. In Excel or PowerPoint, select VBAProject, or in Outlook, select a numbered project, like Project1.
Go to File > Import File.
On the Import File dialog box, go to the folder containing the .bas file you want to import.
Select the .bas file and click Open.
The macros are imported under the Modules folder.
Restore Macros from a Word File
To restore macros you saved in a Word file, open the Word file, select the macro text, and copy it (Ctrl + C).
Then, right-click on Normal in the Project pane in Word, VBAProject in the Project pane in Excel or PowerPoint, or a numbered project, like Project1, in the Project pane in Outlook.
Go to Insert > Module.
Click in the Code window to make sure the cursor is in the window.
Press Ctrl + V to paste the macro code into the Code window.
Click Save or press Ctrl + S to save the macros.
Then, go to File > Close and Return to Microsoft Word (or Outlook or Excel).
Back Up Your Macros
Using one of these methods to save your macros will make sure you have backups of them. And you can use the backups to transfer your macros between computers and share them with others.