VBA & Macro Problems

Fix a Word AutoExec Macro That Does Not Run in a DOCM File

Muhammad TalhaMuhammad Talha Nov 25, 2026 868 views

Question details

Run a macro automatically when a Word document opens or when a new document is created from a template.

Fix a Word AutoExec Macro That Does Not Run in a DOCM File
Product
Microsoft Word
Device & OS
not provided
Scenario
A macro is stored in a macro-enabled Word document and should run automatically.
Observed behavior
The AutoExec macro does not run when the DOCM file opens.
Before you start

Confirm whether you want the macro to run when an existing DOCM opens or when a new document is created from a template. Only enable macros or trust locations for files from sources you trust.

Solution 1Recommended

Use AutoOpen to run the macro when the DOCM opens

Use AutoOpen when the macro should run each time the existing document is opened.

AutoExec is intended for Word startup and global templates, rather than opening an individual DOCM file.

1
Open the VBA editor

Open the DOCM file in Word, then select Developer > Visual Basic. If the Developer tab is hidden, enable it under File > Options > Customize Ribbon.

2
Rename the macro

In the VBA editor's Project pane, open the standard module containing the macro and rename the procedure from AutoExec to AutoOpen. The procedure should take no arguments.

3
Save and test

Select File > Save in Word, close the document, and reopen the DOCM file. If prompted, enable macros only if you trust the file.

4
Check macro security

If the macro still does not run, open File > Options > Trust Center > Trust Center Settings and review Macro Settings. You can also review Trusted Locations and use a trusted location for a file you trust.

Organization policies may apply: Macro settings can be controlled by your organization, and files downloaded from the internet may be blocked. Contact your administrator if you cannot change the relevant setting.
Free Microsoft Office alternative

Edit Word Documents with WPS Office

WPS Office is a free, lightweight alternative for everyday document editing, with a familiar interface and support for common Microsoft Word formats. Open existing files to make migration easier; it does not fix Microsoft Word's AutoExec behavior.

Edit documents in a familiar word-processing interfaceOpen and edit common Microsoft Word formats, including DOC and DOCXUse a free, lightweight alternative for everyday document workMove existing documents into a familiar editing workflow
microsoft office alternative - wps office

Frequently Asked Questions

Why does AutoExec work in Normal but not in my DOCM file?

AutoExec is designed for Word startup and global templates, such as Normal, rather than for opening an individual document. Use AutoOpen in the DOCM file when the macro should run as that document opens.

When should I use AutoNew instead of AutoOpen?

Use AutoNew in a macro-enabled DOTM template when the macro should run as a new document is created from that template. Use AutoOpen when an existing document is opened.

Where can I check whether Word allows macros?

In Word, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Only enable macros for files you trust; your organization may control these settings.

Will opening a DOTM template run AutoNew?

AutoNew is intended to run when you create a new document from the template, not merely when you open the template for editing. Use File > New and select the template to test it.