Document Editing Problems

How to Use Word VBA to Apply AutoCorrect to Existing Text

Chanuka GeekiyanageChanuka Geekiyanage Oct 23, 2026 870 views

Question details

The user wants to apply their pre-configured AutoCorrect entries to text that has already been typed in a document, rather than having it apply only during active typing.

How to Apply AutoCorrect to Existing Text Using Word VBA
Product
Word
Device & OS
not provided
Scenario
The user has existing text in a document and needs to batch-apply AutoCorrect replacements (including multi-word entries) without retyping the text manually.
Observed behavior
AutoCorrect natively triggers only as text is being typed. Existing text remains unchanged unless processed via a specialized macro or retyped.
Before you start

Ensure that the Developer tab is enabled in your word processor to access the VBA editor, and save a backup of your document before running any macros.

Solution 1Recommended

Run a VBA Macro to Process AutoCorrect on Selected Text

Use a custom VBA macro to iterate through selected words in your document, compare them with your AutoCorrect library, and automatically replace matches with their corresponding values.

This macro mimics the behavior of retyping the text by looping through the selected words. It checks if each word matches an AutoCorrect entry name and substitutes the text if a match is found.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu and select 'Module' to create a blank script window.

3
Paste the AutoCorrect Macro

Copy and paste the following code into the module window: Sub AutoCorrectNow2() Dim oWrd As Range Dim Entry As Object Dim iCount As Long, i As Long On Error Resume Next iCount = Selection.Words.Count For i = 1 To iCount Set oWrd = Selection.Words(i) For Each Entry In Word.Application.AutoCorrect.Entries If oWrd.Text = Entry.Name Then oWrd.Text = Entry.Value Exit For ElseIf oWrd.Text = Entry.Name & " " Then oWrd.Text = Entry.Value & " " Exit For End If Next Entry Next i End Sub

4
Run the Macro on Existing Text

Close the VBA editor and return to your document. Highlight the text you want to correct, press Alt + F8, select 'AutoCorrectNow2' from the list, and click 'Run'.

Run a VBA Macro to Process AutoCorrect on Selected Text
Whole Word Matching and Limitations: If you are adapting this macro using Find and Replace logic instead of a word loop, remember to set Find.MatchWholeWord to False for matches inside larger strings, or True for complete-word matches only. Also, note that AutoCorrect provides a single substitution per entry, unlike spelling correction which offers multiple suggestions.
Advanced Document Automation

Manage AutoCorrect and Macros Easily in WPS Writer

WPS Office provides a highly compatible environment for editing documents, automating repetitive tasks, and managing AutoCorrect entries to speed up your workflow without hassle.

  1. 1. Open WPS Writer: Launch WPS Office and open the document you wish to edit.
  2. 2. Configure AutoCorrect: Navigate to Menu > Options > Spell Check to add, remove, or modify your AutoCorrect entries.
  3. 3. Enable the Developer Tab: Go to Options > Customize Ribbon and check the Developer tab to access Macro recording and VBA tools if supported by your version.
Seamless format compatibility with Microsoft Word (.docx)Native support for macros in advanced editions to automate tasksIntuitive UI for managing custom AutoCorrect rules and spelling checksLightweight installation with robust performance for large documents
microsoft office alternative - wps office

Frequently Asked Questions

Can I apply the AutoCorrect macro to the entire document at once?

Yes, you can select the entire document (Ctrl + A) before running the macro. However, looping through every word in a very large document can take a significant amount of time, so processing it in sections is often recommended.

Why doesn't the macro fix regular spelling mistakes?

The macro provided specifically checks the AutoCorrect dictionary, which relies on 1-to-1 predefined substitutions. Spelling corrections require a different approach because they offer multiple suggestions rather than a single automatic replacement.

How do I restrict replacements to whole words only?

The provided loop macro inherently checks against complete words separated by spaces. If you write a custom Find and Replace VBA script instead, you must explicitly use the parameter .MatchWholeWord = True to prevent replacing text inside larger strings.