logo
search
VBA & Macro Problems

How to Move Cursor to Start or End of a Sentence Using Word VBA

Elise WilliamsElise Williams Oct 1, 2026 868 views

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.

How to Move the Cursor to the Start or End of a Sentence with Word VBA
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.
Before you start

Ensure that the Developer tab is enabled in your word processor's settings and that macros are allowed to run in your current document.

Solution 1Recommended

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.

1
Select the sentence

Hold down the Ctrl key (Windows) or Command key (Mac) and click anywhere inside the target sentence to highlight the entire sentence.

2
Move to the beginning

Press the Left Arrow key on your keyboard. The selection will collapse, placing the insertion point exactly at the start of the sentence.

3
Move to the end

Press the Right Arrow key on your keyboard to collapse the selection and place the insertion point at the end of the sentence.

Use Built-in Mouse and Keyboard Shortcuts
Cursor Positioning Note: When using the right arrow key, the cursor may land after the space following the period. Press the Left Arrow key once more to move it right behind the punctuation.

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. 1. Open WPS Writer: Launch WPS Office and open your text document in WPS Writer.
  2. 2. Access the Developer Tools: Navigate to the Tools tab on the ribbon and click on Developer to reveal macro settings.
  3. 3. Launch the VBA Editor: Click on the Visual Basic Editor (or VBA Editor) to paste or write your sentence navigation macros.
  4. 4. Run and Customize: Save your document as a macro-enabled format and assign your new macros to custom keyboard shortcuts.
Fully compatible with Microsoft Word VBA macrosSeamless keyboard shortcut customizationLightweight architecture for fast script execution
microsoft office alternative - wps office

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.