How to Fix Sub or Function Not Defined and Missing Word Macros
Question details
Users need to recover missing macros and resolve a specific VBA error that occurs when attempting to run them.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Attempting to run an existing macro in a Word document or accessing the macro list.
- Observed behavior
- Word displays a 'Sub or Function not defined' error, and the previously available macros are no longer visible in the macro list despite the VBA editor opening successfully.
Before troubleshooting, ensure you have a recent backup of your Normal template and check that macro execution is enabled in your Word Trust Center settings.
Locate and Restore Macros from the Normal Template
Recorded macros are typically stored in the Normal template. Checking and restoring this template can recover missing macros.
By default, Word saves newly recorded macros to a specific module within the global Normal template. If this template is corrupted or replaced, your macros will disappear from the list.
Press the 'Alt + F11' keys on your keyboard simultaneously to open the Visual Basic for Applications (VBA) editor in Word.
In the Project Explorer pane on the left side of the window, locate and expand the project named 'Normal'.
Look for the 'Modules' folder within the Normal project and check if a module named 'NewMacros' is present.
If the 'NewMacros' module is missing or empty, locate your previous backup of the Normal.dotm file and replace the current one in your templates folder to restore the missing macros.

Check Document-Specific and Global Templates
If macros were not stored in the Normal template, they might reside in a specific document or a separate global template that isn't currently loaded.
Switch to WPS Office for a Seamless Word Processing Experience
If you are frequently encountering missing template errors or complex macro issues in Microsoft Word, consider switching to WPS Office. It provides a lightweight, fast, and free alternative with excellent compatibility for your everyday document needs.

Frequently Asked Questions
Why am I getting the 'Sub or Function not defined' error in Word?
This error occurs when the VBA code attempts to call a macro or function that has been deleted, renamed, or is stored in a template/document that is not currently open or loaded in Word.
Where are my recorded macros saved by default?
By default, Word saves newly recorded macros in the Normal template (Normal.dotm) under a module typically named 'NewMacros'.
Can I recover deleted macros in Word?
If you have a backup of your Normal.dotm file or the specific document or global template where the macros were originally saved, you can recover them by restoring that backup file.
How do I edit macros stored in a global template?
To edit macros stored in a global template, you must open the actual template file directly in Word. You cannot edit the macro code while the template is merely loaded as a background add-in.




