VBA & Macro Problems

How to Change Font in All Word Text Boxes Using a VBA Macro

John WilsonJohn Wilson Oct 23, 2026 869 views

Question details

The user needs to apply a specific font to all text within a document, including the text located inside all text boxes, using a VBA macro.

How to Change the Font in All Word Text Boxes Using a VBA Macro
Product
Word
Device & OS
not provided
Scenario
Updating formatting across a large document where standard font changes do not automatically apply to nested shapes like text boxes.
Observed behavior
The goal is to prompt for a font name and automatically apply it universally across the main document text and all text box shapes without manually selecting each one.
Before you start

Verify the exact spelling of the font name you intend to use, and ensure your document is saved as a macro-enabled file (.docm) before running the code.

Solution 1Recommended

Use a VBA Macro to Update Main Text and Text Boxes

Implement a VBA script that prompts for a font name and loops through all document shapes to apply the new font globally.

This macro first updates the main body of the document and then iterates through all shapes. If a shape is identified as a text box (msoTextBox), it applies the new font to the text inside it.

1
Open the VBA Editor

Open your Word document and press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) Editor.

2
Insert a New Module

In the VBA Editor, click on 'Insert' in the top menu bar, and then select 'Module' to open a blank code window.

3
Paste the Macro Code

Copy and paste the FontNameAll macro script into the module window. Ensure the code includes the InputBox prompt for the font name, sets ActiveDocument.Range.Font.Name, and loops through ActiveDocument.Shapes to modify TextFrame.TextRange.Font.Name for msoTextBox types.

4
Run the Macro

Close the VBA Editor. Back in your document, press Alt + F8 to open the Macros dialog box. Select 'FontNameAll' from the list and click 'Run'.

5
Enter the Font Name

When the prompt appears, type the exact name of your desired font (e.g., 'Arial' or 'Times New Roman') and click 'OK' to apply the changes.

Use a VBA Macro to Update Main Text and Text Boxes
Font Name Accuracy: The macro will not display an error message if you enter a font name that does not exist on your system. Always double-check the font spelling before running the macro.
Efficient Word Processing with WPS Office

Run Macros and Format Documents Seamlessly in WPS Writer

WPS Writer offers extensive compatibility with Microsoft Word documents, including support for VBA macros in specific professional versions. You can easily manage complex document formatting and automate repetitive tasks across all your files.

  1. 1. Open Your Document: Launch WPS Writer and open your macro-enabled document.
  2. 2. Access the Developer Tab: Navigate to the 'Developer' tab on the top ribbon to access advanced tools.
  3. 3. Open the Macros Manager: Click 'Macros' or press Alt+F8 to view and manage your document's VBA macros.
  4. 4. Execute the Macro: Select your text-box formatting macro from the list and click 'Run' to apply the font changes.
Highly compatible with Microsoft Word .doc, .docx, and .docm formatsSupports advanced document formatting and text box managementLightweight, fast, and features a familiar user interfaceFree basic tools with seamless migration from other office suites
microsoft office alternative - wps office

Frequently Asked Questions

Why didn't the font change after I ran the macro?

This typically happens if the font name was misspelled in the input prompt. Because the macro does not return an error for non-existent fonts, you should verify the exact font name in your font library and run the macro again.

Will this macro change text inside grouped shapes or tables?

This specific macro targets the main document range and standalone text boxes (msoTextBox). Text inside tables is naturally covered by the main document range, but text in grouped shapes may require modifying the VBA script to loop through grouped sub-items.

Can I undo the macro's changes if I make a mistake?

Yes, you can typically press Ctrl + Z immediately after running the macro to revert the font changes across the document and text boxes.