Formatting Issues

How to Remove Underlining from Trailing Spaces in Word

Steve KSteve K Oct 29, 2026 869 views

Question details

The user needs to remove underlining from blank spaces at the end of hyperlinks or underlined text without altering the formatting of the actual words.

How to Remove Underlining from Trailing Spaces in Word
Product
Word
Device & OS
not provided
Scenario
Finalizing document formatting where hyperlinks or emphasized text accidentally include an underlined blank space at the end.
Observed behavior
Trailing spaces following hyperlinks or underlined words incorrectly inherit the underline formatting, creating an unappealing extended line.
Before you start

Make sure to save a backup copy of your document before running any VBA macros, as macro executions cannot easily be undone using the standard Undo feature.

Solution 1Recommended

Use a VBA Macro to Clear Trailing Underlines

Because Word's Find and Replace tool struggles to reliably isolate and modify trailing spaces adjacent to formatted text, utilizing a VBA macro is the most effective automated solution.

This macro specifically targets the final space in a string of underlined text or a hyperlink, trims it, and replaces it with a normal, non-underlined space.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.

2
Insert a New Module

Click on 'Insert' in the top menu, then select 'Module' to open a blank script window.

3
Apply the Macro Code

Paste your preferred macro script designed to loop through hyperlinks and standard text to trim trailing spaces. (Usually found in Word MVP forums or formatting guides).

4
Run the Macro

Press F5 or click the 'Run' button. The macro will scan the document and remove the underline from the trailing spaces.

Use a VBA Macro to Clear Trailing Underlines
Handling Multiple Spaces: This type of macro typically only modifies the final space in a sequence. If you have multiple consecutive underlined spaces, you may need to run the macro repeatedly until all of them are cleared.
Seamless Document Formatting

Fix Formatting Issues Easily with WPS Office

WPS Writer offers an intuitive interface and precise formatting tools, making it exceptionally easy to manage hyperlinks, text styles, and hidden characters without needing complex macros.

  1. 1. Open your Document in WPS Writer: Launch WPS Office and open your .docx file containing the formatting issues.
  2. 2. Reveal Blank Spaces: Click the 'Show/Hide Editing Marks' icon on the Home tab so you can clearly see the trailing space characters.
  3. 3. Select and Clear Formatting: Highlight the unwanted trailing space, then click the Underline icon (or press Ctrl + U) to instantly clear the underline formatting from just that space.
Free and lightweight Office suiteHighly compatible with Microsoft Word (.docx) documentsIntuitive UI for precise text and hyperlink formatting adjustmentsClear formatting marks to easily spot and fix trailing spaces
microsoft office alternative - wps office

Frequently Asked Questions

Why does the underline extend past my text?

This happens when you press the spacebar immediately after typing an underlined word while the underline formatting is still active. The word processor assumes you want to continue underlining the next characters, including spaces.

Can I use Find and Replace to fix trailing underlines?

Using the standard Find and Replace tool is generally unreliable for this specific task. The tool struggles to differentiate between a space that is part of a formatted string and one that isn't, often leading to inconsistent results.

How do I prevent trailing spaces from being underlined in the future?

The easiest way to prevent this is to toggle off the underline formatting (by pressing Ctrl + U) immediately after typing the last letter of your word, before pressing the spacebar to start the next word.

Does this issue affect printed documents or just the digital display?

Underlined trailing spaces will appear on the printed document as well. It's best practice to remove them to ensure your final printed or exported PDF document looks professional and clean.