Hide Non-Highlighted Text in Word with a VBA Macro
Question details
Use a Word VBA macro to hide text that has no highlight while keeping highlighted text visible.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- The user wants to focus on highlighted passages in a document without deleting the remaining text.
- Observed behavior
- Non-highlighted text should have the Hidden font attribute applied, while highlighted text remains visible.
Apply highlights using Word’s Home > Text Highlight Color tool; font color and paragraph shading are not the same as highlighting. The macro below processes the main document body, not headers, footers, or text boxes.
Run a Word VBA macro to hide non-highlighted text
Use this macro to apply Hidden formatting to non-highlighted characters in the main document body and make highlighted characters visible.
In Word, select File > Save As and choose Word Macro-Enabled Document (*.docm) if you want to store the macro in the document.
On Windows, press Alt+F11. In the VBA editor, select the document’s project, then choose Insert > Module.
Paste this code into the module: Sub HideNonHighlightedText() Dim charRange As Range For Each charRange In ActiveDocument.Content.Characters If charRange.HighlightColorIndex = wdNoHighlight Then charRange.Font.Hidden = True Else charRange.Font.Hidden = False End If Next charRange End Sub
Return to Word, press Alt+F8 on Windows, select HideNonHighlightedText, and click Run. Enable macros only if you trust the document and its source.
Go to File > Options > Display and clear Hidden text and Show all formatting marks. Non-highlighted text remains in the document but should no longer appear on screen.

Work with Word documents in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. It supports common Word formats for an easier move between applications, but it does not fix or replace the Word VBA macro described above.

Frequently Asked Questions
How can I see the hidden text again in Word?
Go to File > Options > Display and select Hidden text. To remove Hidden formatting permanently, select the text, open the Font dialog, and clear Hidden.
Does the macro recognize colored text or paragraph shading?
No. It checks Word’s text highlight attribute. Use Home > Text Highlight Color to mark the passages you want to keep visible.
Will the macro hide text in headers and footers?
No. The supplied macro processes ActiveDocument.Content, which covers the main document body. Headers, footers, and text boxes require additional code.
Why can I still see the non-highlighted text after running the macro?
In File > Options > Display, clear both Hidden text and Show all formatting marks. Hidden text can still be displayed when those options are enabled.
Why should I save the document as a DOCM file?
A Word Macro-Enabled Document (*.docm) can store the macro in the document. Choose File > Save As and select that format if you want the macro to remain available in the file.




