Office Settings & Configuration

How to Use VBA to Capitalize Every Word in a Word Document

Camila MilosovichCamila Milosovich Oct 29, 2026 870 views

Question details

The user wants to use a VBA macro to apply title-style capitalization to all words in a Microsoft Word document for efficient batch processing.

How to Use VBA to Capitalize Every Word in a Word Document
Product
Microsoft Word
Device & OS
not provided
Scenario
Automating the process of changing text case to Title Case across an entire document without manual selection.
Observed behavior
The user requires a programmatic method to change the case of the entire active document's range, bypassing the manual Change Case ribbon button.
Before you start

Before running any VBA macro that modifies your entire document, save a backup copy of your file to prevent accidental formatting changes or data loss.

Solution 1Recommended

Run a VBA Macro to Apply Title Case to the Entire Document

Use a short VBA script to instantly change the case of all text in the active document to Title Case.

This solution uses Word's built-in Visual Basic for Applications (VBA) editor to apply the wdTitleWord property to the entire document range. This is especially useful for batch processing multiple documents.

1
Open the VBA Editor

Press Alt + F11 on your keyboard while Microsoft Word is open 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 from the dropdown list to create a blank workspace for your code.

3
Paste the Macro Code

Type or paste the following code into the module window: Sub CapitalizeWords() ActiveDocument.Range.Case = wdTitleWord End Sub.

4
Run the Macro

Close the VBA Editor. Back in your Word document, press Alt + F8 to open the Macros dialog box. Select CapitalizeWords from the list and click Run to instantly capitalize every word in your document.

Run a VBA Macro to Apply Title Case to the Entire Document
Macro Security and Saving: Ensure that macros are enabled in your Word Trust Center settings. If you plan to keep this macro for future use, remember to save your document as a Word Macro-Enabled Document (.docm) or add the code to your trusted Normal.dotm global template.
Easy Word Processing

Capitalize Text Easily with WPS Office

While VBA is powerful for automation, WPS Writer offers an intuitive built-in Change Case feature that lets you capitalize every word in just a few clicks. For advanced users, WPS Office also provides robust VBA support to run your existing Word macros seamlessly.

  1. 1. Select the Text: Open your document in WPS Writer and press Ctrl + A to select the entire document range.
  2. 2. Locate the Change Case Tool: Navigate to the Home tab on the top ribbon menu and look for the Change Case icon, typically represented by the letters 'Aa'.
  3. 3. Apply Capitalize Each Word: Click the 'Aa' icon and select 'Capitalize Each Word' from the dropdown menu to instantly format your text without writing any code.
Highly compatible with Microsoft Word DOCX and DOCM formatsBuilt-in intuitive text formatting and case-changing toolsAdvanced versions fully support VBA for macro automationFree and lightweight alternative to Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Can I apply this VBA macro to specific paragraphs instead of the whole document?

Yes. Instead of using ActiveDocument.Range.Case, you can modify the macro to target Selection.Range.Case. This allows you to highlight specific text or paragraphs before running the macro, ensuring only the selected text is capitalized.

Why did my macro disappear after closing the document?

If you saved the document as a standard DOCX file, the macro code is automatically discarded for security reasons. You must use 'Save As' and select 'Word Macro-Enabled Document (*.docm)' to preserve the VBA code for future sessions.

Does wdTitleWord automatically skip small words like 'and' or 'the'?

No. The wdTitleWord property in Word VBA strictly capitalizes the first letter of every single word in the specified range. It does not evaluate grammar or automatically apply true stylistic title case rules, so prepositions and conjunctions will also be capitalized.