Created
January 31, 2023 14:21
-
-
Save githubyouser/4a9a5ab9f32680b16c73fbd28181bac9 to your computer and use it in GitHub Desktop.
Word VBA: Find shaded text and replace with underlining
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'https://www.msofficeforums.com/word-vba/49481-remove-shading-specific-color-document-multiple-shading.html | |
Sub Macro5() | |
Dim iCol As Long | |
iCol = Selection.Shading.BackgroundPatternColor | |
With ActiveDocument.Range.Find | |
.ClearFormatting | |
.Replacement.ClearFormatting | |
.Text = "" | |
.ParagraphFormat.Shading.BackgroundPatternColor = iCol | |
.Replacement.Font.Underline = wdUnderlineSingle | |
.Execute Replace:=wdReplaceAll | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this script, select the whole paragraph with the particular shading that you want to replace and then run the script. It will find all other paragraphs with the same shading and add underlining to them.