How to Use VBA to Capitalize Every Word in a Word Document
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.

- 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 running any VBA macro that modifies your entire document, save a backup copy of your file to prevent accidental formatting changes or data loss.
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.
Press Alt + F11 on your keyboard while Microsoft Word is open to launch the Visual Basic for Applications (VBA) Editor.
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.
Type or paste the following code into the module window: Sub CapitalizeWords() ActiveDocument.Range.Case = wdTitleWord End Sub.
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.

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. Select the Text: Open your document in WPS Writer and press Ctrl + A to select the entire document range.
- 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. 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.

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.




