Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-27-2023, 08:57 AM
gmaxey gmaxey is offline VBA Code to remove specific highlight Windows 10 VBA Code to remove specific highlight Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

First, while a common mistake, I am not Gmayor.


If you want to get rid of red highlighting in a mix of red and some other color:

Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Dim oChr As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Highlight = True
    While .Execute
      Select Case oRng.HighlightColorIndex
        Case Is = 9999999
          For Each oChr In oRng.Characters
            If oChr.HighlightColorIndex = wdRed Then
              oChr.HighlightColorIndex = wdAuto
            End If
          Next
        Case Is = wdRed
          oRng.HighlightColorIndex = wdAuto
      End Select
      oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
or like this:


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Dim oChr As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "*"
    .MatchWildcards = True
    .Highlight = True
    While .Execute
      Select Case oRng.HighlightColorIndex
        Case Is = wdRed
          oRng.HighlightColorIndex = wdAuto
      End Select
      oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
highlight, macro, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to remove specific highlight VBA Highlight numbers only after or before specific words help Shelley Lou Word VBA 12 08-09-2022 03:02 AM
VBA Code to remove specific highlight Remove highlight with specific color rekent Word VBA 2 08-01-2020 10:59 AM
How to highlight lines containing specific words SixStringSW Word VBA 4 06-03-2018 03:57 PM
VBA to highlight specific values in the spreadsheet daiwuliz Excel 6 05-23-2018 10:30 AM
Highlight the current cell without using code parshla Excel 0 09-08-2016 08:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft