How to Create a Word VBA Macro to Split Text into Sentences
Question details
The user needs a Word VBA macro to automatically format unpunctuated text, such as YouTube transcripts, by splitting it into proper sentences, adding periods, and capitalizing the first words.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Formatting raw text or YouTube transcripts that lack proper sentence boundaries, capitalization, and punctuation to avoid repetitive manual corrections.
- Observed behavior
- Manual corrections are currently required to capitalize first words and add periods, prompting the need for automated transformation rules via VBA.
Before running any VBA macro, ensure you have a clear before-and-after sample of your text to define specific transformation rules, as automated macros rely on consistent markers to detect sentence boundaries accurately.
Define Transformation Rules and Create the Macro
Setting up a custom VBA macro in Word to process unformatted transcript text based on specific character length, line breaks, or existing markers.
Because raw transcripts lack standard punctuation, a shortcut alone cannot reliably detect where a sentence ends. A VBA macro needs clear rules, such as identifying line breaks or specific transcript markers, to insert periods and capitalize the next letter.
Go to File > Options > Customize Ribbon, and check the 'Developer' box in the right column to enable macro tools.
Click 'Visual Basic' on the Developer tab or press ALT + F11 on your keyboard.
In the Visual Basic Editor, click Insert > Module to create a blank workspace for your code.
Write a script that loops through paragraphs or uses Regular Expressions (RegEx) to locate text boundaries, append a period, and use the 'UCase' function to capitalize the first letter of the following word.
Press F5 or go to Developer > Macros, select your newly created macro, and click Run on your selected transcript text.

Use WPS Writer to Automate Text Formatting
WPS Writer fully supports VBA macros, allowing you to seamlessly run scripts that format transcripts, split sentences, and auto-capitalize text. It offers an intuitive interface and high compatibility with standard Word document formats.
- 1. Open your document: Launch WPS Writer and open the raw transcript or unformatted text file.
- 2. Access the Developer Tools: Go to the Tools tab and click on the Developer option to access the macro settings.
- 3. Open the VBA Editor: Click on Visual Basic Editor (ALT + F11) to paste or write your custom sentence-splitting macro.
- 4. Execute the script: Run the macro to automatically insert periods and capitalize the first letters of your text.

Frequently Asked Questions
Why doesn't the macro capitalize the first word of every line automatically?
If the macro relies strictly on periods to detect the start of a new sentence, it will not capitalize the first word of a new line unless a period preceded it or the macro code explicitly checks for line breaks using standard paragraph markers.
Can I use Find and Replace instead of a VBA macro for this?
Wildcard Find and Replace can handle simple formatting, like capitalizing words after existing periods, but it cannot intelligently decide where a sentence should end in an unpunctuated block of text without the complex logic provided by a VBA script.
Are Microsoft Word VBA macros compatible with WPS Office?
Yes, WPS Office supports VBA macros. You can typically copy and paste standard Word VBA scripts directly into the WPS Visual Basic Editor and they will function perfectly.
How do I assign my new text-formatting macro to a keyboard shortcut?
Go to File > Options > Customize Ribbon, click Customize next to Keyboard shortcuts, select Macros from the Categories list, choose your macro, and assign a new shortcut key combination like Ctrl+Shift+M.




