How to Move Cursor to Start or End of a Sentence Using Word VBA
Question details
A user needs to move the insertion point to the exact beginning or end of the current sentence, taking into account trailing spaces after the period.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Automating text navigation in long documents to quickly edit or append content at sentence boundaries.
- Observed behavior
- When using default VBA commands to jump to the end of a sentence, the cursor often lands after the trailing space instead of immediately after the punctuation mark.
Ensure that the Developer tab is enabled in your word processor's settings and that macros are allowed to run in your current document.
Use Built-in Mouse and Keyboard Shortcuts
A fast, non-VBA alternative using built-in selection shortcuts to jump to the start or end of a sentence.
If you prefer not to write or maintain VBA code, you can use built-in modifier keys to instantly select a sentence and navigate its boundaries. This method works natively on both Windows and Mac environments.
Hold down the Ctrl key (Windows) or Command key (Mac) and click anywhere inside the target sentence to highlight the entire sentence.
Press the Left Arrow key on your keyboard. The selection will collapse, placing the insertion point exactly at the start of the sentence.
Press the Right Arrow key on your keyboard to collapse the selection and place the insertion point at the end of the sentence.

Create VBA Macros for Sentence Navigation
Write dedicated VBA procedures to collapse the selection specifically at the beginning or end of the current sentence range.
Automate Text Navigation using VBA in WPS Office
WPS Writer offers robust support for VBA macros, allowing you to easily run custom scripts that navigate text, automate formatting, and boost your document editing efficiency.
- 1. Open WPS Writer: Launch WPS Office and open your text document in WPS Writer.
- 2. Access the Developer Tools: Navigate to the Tools tab on the ribbon and click on Developer to reveal macro settings.
- 3. Launch the VBA Editor: Click on the Visual Basic Editor (or VBA Editor) to paste or write your sentence navigation macros.
- 4. Run and Customize: Save your document as a macro-enabled format and assign your new macros to custom keyboard shortcuts.

Frequently Asked Questions
How do I assign my custom VBA macro to a keyboard shortcut?
In your word processor, navigate to Options > Customize Ribbon, and click the 'Customize...' button next to Keyboard shortcuts. Select 'Macros' from the Categories list, choose your specific macro, and press your desired key combination in the 'Press new shortcut key' field.
Why does the cursor jump to the space after the period when using a macro?
In VBA, the 'Sentence' object includes the trailing space that follows the punctuation mark. To place the cursor exactly after the period, your macro must identify the sentence range, step back by one character position, and then collapse the selection.
Can I select a sentence without using a macro?
Yes. You can hold down the Ctrl key (Windows) or the Command key (Mac) and click anywhere inside the sentence to instantly select the entire sentence.




