How to Use Word VBA to Apply AutoCorrect to Existing Text
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.

- 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.
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.
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.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the VBA editor, click on 'Insert' in the top menu and select 'Module' to create a blank script window.
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
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'.

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. Open WPS Writer: Launch WPS Office and open the document you wish to edit.
- 2. Configure AutoCorrect: Navigate to Menu > Options > Spell Check to add, remove, or modify your AutoCorrect entries.
- 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.

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.




