Fix Word Runtime Error 5173 in a Template
Question details
The user needs to resolve runtime error 5173 when a Word template button modifies text.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A template button runs code that modifies text and may create or change a conflicting style.
- Observed behavior
- The error continues across template versions and remains after Safe Mode, a fresh template, deletion of Normal.dotm, and Office reinstallation.
Identify the template button that triggers the error and note the exact error message. If you have access to the template's VBA code, be ready to inspect the line highlighted when the error occurs.
Inspect the Template Macro for a Style Conflict
Use this approach when the error persists in Safe Mode and occurs at a specific template button.
A macro may attempt to create a style that already exists or change a built-in style in a way that causes a conflict. Reinstalling Office will not necessarily correct an error in the template code.
Open the affected template or a document based on it, then click the button that causes runtime error 5173.
If the error dialog offers Debug, click it to open the VBA editor and identify the highlighted statement. If Debug is unavailable or the project is protected, ask the template developer to inspect the macro.
In the VBA editor, inspect the style name and the statement that creates, renames, or modifies the style. Check the document's Styles pane from Home for an existing style with the same name.
Update the macro to use the existing style when appropriate or give a new custom style a distinct name. For built-in styles, use the appropriate Word built-in style constant where possible, then run the template button again.

Test Word Add-ins in Safe Mode
Use Safe Mode to check whether an add-in contributes to the error.
Repair Office if Word Also Fails Outside the Template
Consider an Office repair when Word has broader startup or document problems, rather than only a failing template button.
Work With Word Documents in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and compatibility with common Word formats, making it easy to move everyday document work. It does not repair Word runtime errors, and Word template macros may not work in WPS Writer.

Frequently Asked Questions
Why does error 5173 still appear in Word Safe Mode?
Safe Mode can help isolate add-ins, but it does not necessarily fix a conflict in the template's own code. If the same button fails in Safe Mode, inspect the failing VBA statement and the styles it uses.
How do I find the macro line causing the error?
Click Debug in the runtime error dialog if it is available. Word opens the VBA editor and highlights the statement where execution stopped. If the project is protected or Debug is unavailable, contact the template developer.
Where can I disable Word add-ins?
In Word, open File > Options > Add-ins. Choose COM Add-ins or Word Add-ins in the Manage list and click Go. Disable one add-in at a time and retest the template button.
Will reinstalling Office fix a conflicting template style?
Not necessarily. If the template macro tries to create an existing style or incorrectly modifies a built-in style, the macro may need to be corrected even after Office is reinstalled.
Can WPS Writer fix the Word template macro?
WPS Writer can be an alternative for everyday DOC and DOCX documents, but it does not repair Microsoft Word runtime errors. Word template macros and add-ins may not work in WPS Writer.




