View Single Post
 
Old 06-17-2023, 05:06 AM
Themillen Themillen is offline Windows 11 Office 2021
Novice
 
Join Date: Feb 2023
Posts: 4
Themillen is on a distinguished road
Default

If anyone can find the time, do you know how I can change this macro below from making the selected text bold to higlight red? Simply change it to ".Replacement.HighlightColorIndex = wdRed: .Replacement.Highlight = True" doesn't word for some reason. Thanks for your time!



Sub LinkingWords_SelectedText_Bold()
Dim vWords As Variant
Dim sWord As Variant

' Split the words into smaller arrays
vWords = Array( _
Array("in spite of", "while", "whereas", "though", "admittedly", "regardless"), _
Array("So", "To summarize", "On the other side", "In conclusion", "Lastly", "In conclusion", "In short"))


' Process each sub-array separately
For Each subArray In vWords
For Each sWord In subArray
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Bold = True
With Selection.Find
.Text = sWord
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next sWord
Next subArray
End Sub
Reply With Quote