Share via

Remove highlighting from specific words

Anonymous
2022-04-01T05:00:21+00:00

As part of my editing of my reports, I use macros to highlight specific words. However this sometimes results in some words being green highlighted that I am not interested in. Is there a macro or keyboard shortcut that will remove green highlighting from specific words?

For example, lets say in the below text, I have ran a macro that highlights in green all instances of adipiscing and scelerisque. Can I then run a macro that asks me what words I want un-highlighted? I can then input those words and the macro will remove the highlighting from those specific words.

Scelerisque adipiscing scelerisque adipiscing scelerisque, adipiscing adipiscing scelerisque. Proin scelerisque, adipiscing scelerisque venenatis scelerisque, dui scelerisque adipiscing scelerisque, quis scelerisque adipiscing scelerisque at scelerisque. Nam scelerisque diam scelerisque, commodo adipiscing.
Microsoft 365 and Office | Word | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2022-04-01T07:15:39+00:00

    Use a macro containing the following code:

    Dim Findstr As String

    Findstr = InputBox("Insert the word from which the highlight is to be removed")

    Selection.HomeKey wdStory

    With Selection.Find

    Do While .Execute(FindText:=Findstr, Forward:=True, \_ 
    
    MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=True) = True 
    
        With Selection 
    
            .Range.HighlightColorIndex = wdAuto 
    
            .Collapse wdCollapseEnd 
    
        End With 
    
    Loop 
    

    End With

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2022-04-01T07:00:07+00:00

    The following should work

    Sub Macro1()
    Dim oRng As Range
    Dim sText As String
    sText = InputBox("Enter word to find")
    Set oRng = ActiveDocument.Range
    With oRng.Find
    .Highlight = True
    .Text = sText
    .MatchWholeWord = True
    Do While .Execute
    If oRng.HighlightColorIndex = wdBrightGreen Then
    oRng.HighlightColorIndex = wdNoHighlight
    End If
    Loop
    End With
    End Sub

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2022-04-02T05:02:02+00:00

    Many thanks to the usual people for sharing your expertise.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-04-01T05:32:10+00:00

    Download a copy of this free ebook. It has one section specifically on "Editing-Highlighting"

    Macros for Editors (PDF Download)

    http://archivepub.co.uk/book.html

    by Paul Beverly.

    This is a free book, which you can download (in zip format) (version: 20 Jan 2022). It contains over 800 macros that will help with a range of different tasks around writing and editing using Microsoft Word.

    .

    Also check the section on the "FRedit" macro

    .

    Was this answer helpful?

    0 comments No comments