VBA & Macro Problems

How to Run Multiple Wildcard Replacements in Word with One Macro

Adam DavisAdam Davis Oct 16, 2026 873 views

Question details

The user wants to automate multiple wildcard text replacements in a specific sequence using a single VBA macro.

How to Run Multiple Wildcard Replacements in Word with One Macro
Product
Microsoft Word
Device & OS
not provided
Scenario
Performing several complex wildcard text replacements in a specific order, where doing it manually via the Find and Replace dialog is too time-consuming.
Observed behavior
The user seeks a one-click VBA solution to execute a predefined series of wildcard replacements automatically and sequentially.
Before you start

Ensure the Developer tab is enabled in your Word ribbon and save a backup copy of your document before running bulk replacement macros to prevent accidental data loss.

Solution 1Recommended

Use a Master VBA Procedure to Call Multiple Replacement Macros

Create individual macros for each specific wildcard replacement, then build a master macro to execute them sequentially in a single click.

By breaking down each wildcard find-and-replace operation into its own sub-procedure, your code remains clean, easy to troubleshoot, and simple to update. A 'Main' procedure will then trigger each step in the exact order required.

1
Open the VBA Editor

Press Alt + F11 to open the Microsoft Visual Basic for Applications window, then click Insert > Module to create a new module space for your code.

2
Create individual wildcard replacement macros

Write a separate Sub procedure for your first replacement. Ensure you set .MatchWildcards = True and use .Execute Replace:=wdReplaceAll. Name it something like Sub Macro1().

3
Handle special characters if necessary

If your replacement text requires special symbols like a star, use VBA's ChrW() function (e.g., ChrW(9733)) and concatenate it with your replacement string using the '&' operator.

4
Define remaining replacement macros

Repeat the process for the rest of your text patterns, saving them as Sub Macro2(), Sub Macro3(), and so on, keeping the required chronological sequence in mind.

5
Create and run the Master Macro

Write a final Sub MainMacro() that calls Macro1, Macro2, etc., in order. Close the VBA editor, press Alt + F8 in Word, select MainMacro, and click Run to perform all wildcard replacements instantly.

Use a Master VBA Procedure to Call Multiple Replacement Macros
VBA Tips: Always set .Wrap = wdFindStop or wdFindContinue explicitly in your VBA Find object to control how the search behaves when it reaches the end of the document.
Free Microsoft Office alternative

Automate Document Formatting with WPS Office Writer

If you work heavily with document formatting and complex text replacements, WPS Office Writer offers exceptional compatibility with Microsoft Word files (.docx) and supports advanced text manipulation features in a lightweight interface.

  1. 1. Download the software: Visit the official WPS website and download the free WPS Office installer.
  2. 2. Install WPS Office: Run the downloaded installation file and follow the brief on-screen instructions.
  3. 3. Open your documents: Launch WPS Writer to seamlessly open and edit your existing Word documents with full formatting preserved.
Highly compatible with Microsoft Word documents (.doc, .docx).Supports advanced Find and Replace with wildcards for complex text patterns.Lightweight design ensures fast loading and smooth operation even with large files.Familiar user interface makes migrating from Microsoft Office effortless.
microsoft office alternative - wps office

Frequently Asked Questions

How do I insert special Unicode characters like a star symbol in a VBA replacement?

You can use the ChrW() function in VBA alongside the character's decimal code. For example, ChrW(9733) inserts a solid star symbol into the replacement text string.

Why does my wildcard search macro not replace anything?

Ensure that the .MatchWildcards property of your Find object is set to True. Additionally, verify that your wildcard pattern syntax is strictly correct, as wildcards in Word/VBA behave differently than standard regular expressions.

Can I combine all replacements into one single macro procedure?

Yes, you can reuse the With oRng.Find block multiple times sequentially within a single Sub by updating the .Text and .Replacement.Text properties before each .Execute command. However, using separate macros makes troubleshooting much easier.