Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 03-27-2023, 05:01 PM
syl3786 syl3786 is offline VBA Code to remove specific highlight Windows 10 VBA Code to remove specific highlight Office 2019
Advanced Beginner
VBA Code to remove specific highlight
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
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
I deeply apologize for called the wrong name. I made a mistake. Thank you so much for your help! They works well!
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 08:49 PM.


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