Template Issues

Fix Word Runtime Error 5173 in a Template

Ayan MasoodAyan Masood Nov 22, 2026 868 views

Question details

The user needs to resolve runtime error 5173 when a Word template button modifies text.

Fix Word Runtime Error 5173 in a Template
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.
Before you start

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.

Solution 1Recommended

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.

1
Reproduce the error

Open the affected template or a document based on it, then click the button that causes runtime error 5173.

2
Inspect the failing line

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.

3
Check the style operation

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.

4
Correct and retest the code

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.

Inspect the Template Macro for a Style Conflict
Access to the code: Editing a protected VBA project requires access from its owner. Share the highlighted line and error message with the template developer if you cannot edit it.
Free Microsoft Office alternative

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.

Create and format documents with a familiar word-processing interfaceOpen and edit common Microsoft Word formats, including DOC and DOCXUse styles to keep document formatting consistentMove everyday document work to a lightweight, free office suite
microsoft office alternative - wps office

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.