![]() |
#1
|
|||
|
|||
![]()
Hi community,
Thank you experts for helping me to edit the VBA codes in the previous post (https://www.msofficeforums.com/word-...highlight.html) I have encountered another issue. When I tried to remove two highlight colours at the same time, the same issue came out again. That is, two highlight colours connected together cannot be identified by the macro and be removed. (See attached file as demo) Code:
Sub ClearTurquoise() Call ClearPink Dim oRngStory As Range For Each oRngStory In ActiveDocument.StoryRanges Do With oRngStory.Find .Highlight = True Do While .Execute If oRngStory.HighlightColorIndex = wdTurquoise Then oRngStory.HighlightColorIndex = wdNoHighlight oRngStory.Collapse 0 End If Loop End With 'Get next linked story (if any) Set oRngStory = oRngStory.NextStoryRange Loop Until oRngStory Is Nothing Next lbl_exit: Exit Sub End Sub Sub ClearPink() Dim oRngStory As Range For Each oRngStory In ActiveDocument.StoryRanges Do With oRngStory.Find .Highlight = True Do While .Execute If oRngStory.HighlightColorIndex = wdpink Then oRngStory.HighlightColorIndex = wdNoHighlight oRngStory.Collapse 0 End If Loop End With 'Get next linked story (if any) Set oRngStory = oRngStory.NextStoryRange Loop Until oRngStory Is Nothing Next lbl_exit: Exit Sub End Sub Your help will be greatly appreciated! |
Tags |
highlight, vba, word macro |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
QQQ | Word | 15 | 10-17-2022 11:40 AM |
How to change colors to time values | Ashikido | Excel | 6 | 02-01-2021 11:37 AM |
Text/highlight colors in selection boxes changed | kathleen | Word | 0 | 01-10-2018 07:45 PM |
Need to put two highlight buttons on toolbar in different colors | davidmrt | Word | 6 | 12-11-2011 05:54 AM |
![]() |
billy589 | PowerPoint | 1 | 10-04-2010 02:33 PM |