logo
search
VBA & Macro Problems

How to Fix VBA Error 5097 When Updating Word Content Controls

Bushra ParveenBushra Parveen Oct 20, 2026 868 views

Question details

The user needs to resolve VBA Error 5097, which occurs when running a macro to update multiple content controls while Track Changes is enabled.

How to Fix VBA Error 5097 When Updating Word Content Controls
Product
Microsoft Word
Device & OS
not provided
Scenario
Running a Word VBA macro to automatically update the text of hundreds of content controls selected by their tags.
Observed behavior
The macro fails with Error 5097 (application-defined or object-defined error) when Track Changes is enabled, but runs successfully when revision tracking is disabled.
Before you start

Ensure you have access to the VBA Editor (Alt + F11) and save a backup copy of your document before modifying the macro code.

Solution 1Recommended

Temporarily Disable Track Changes in the VBA Code

Modify your macro to automatically turn off Track Changes before updating the content controls, preventing the application-defined error.

Updating a large number of content controls while Word is actively tracking revisions can cause an object-defined error. Disabling the feature during execution prevents this memory conflict and allows the procedure to run smoothly.

1
Open the VBA Editor

Press Alt + F11 on your keyboard while in Word to open the Microsoft Visual Basic for Applications window.

2
Disable Track Changes

Locate your macro code and add `ActiveDocument.TrackRevisions = False` at the very beginning of the update routine.

3
Re-enable Track Changes

Add `ActiveDocument.TrackRevisions = True` at the end of the routine to re-enable tracking after the content controls have been updated.

4
Run the Macro

Save the macro and run the procedure again to confirm that Error 5097 is successfully resolved.

Temporarily Disable Track Changes in the VBA Code
Revision Tracking Limits: Any changes made by the macro to the content controls while tracking is disabled will not be recorded as revisions.
Free Microsoft Office alternative

Switch to WPS Office for a Smoother Document Experience

If you frequently encounter application-defined errors and complex VBA issues in Microsoft Word, consider switching to WPS Office. It provides a lightweight, highly compatible alternative with seamless Microsoft Office format support and powerful document processing capabilities.

  1. 1. Download and Install: Visit the official WPS website to download the free installation package for your operating system.
  2. 2. Open Your Document: Launch WPS Writer and open your existing Word document to continue working seamlessly.
  3. 3. Edit with Ease: Enjoy a familiar interface and robust editing tools without the heavy resource usage.
Fully compatible with Microsoft Word formats, including .docx and .docmFamiliar user interface that requires no learning curveLightweight software that runs quickly and efficiently without memory bloatFree to download and use for all your daily document tasks
microsoft office alternative - wps office

Frequently Asked Questions

What does VBA Error 5097 mean in Word?

Error 5097 is an 'application-defined or object-defined error'. It indicates that the VBA code is attempting to perform an action that the application's object model cannot handle in its current state, such as processing too many tracked changes at once.

Why does Track Changes conflict with updating content controls?

When a macro updates hundreds of content controls simultaneously, having Track Changes enabled forces the application to record every single modification into memory. This can overwhelm the memory buffer and trigger an object-defined error.

Is the SelectContentControlsByTag method case-sensitive?

Yes. If your VBA code looks for a tag named 'UpdateData' but the document's content control is tagged as 'updatedata', the method will not find the control. This mismatch can lead to unexpected macro errors.

Can I track the macro's changes without getting Error 5097?

If you absolutely need to track the macro's changes, try breaking the update process into smaller batches using a loop, or inserting a `DoEvents` command in your VBA code to allow the application time to process the revisions sequentially.