View Single Post
 
Old 09-28-2022, 05:41 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Nicknamednick View Post
However, when I ran the macro on a regular document, it had less than desirable effects. Many of the words were bolded, but some were only partially bolded.
Words that are partially bolded indicate that your Find terms didn't include the whole of those words. This is a problem that arises from having both single words and phrases in the same list, as one can't use:
.MatchWholeWord = True
when phrases are present. One way around that would be to test each term for the presence of one or more spaces. For example:
Code:
  'Process each string from the List
  For i = 1 To UBound(Split(xlFList, "|"))
    If UBound(Split(Split(xlFList, "|")(i), " ")) = 0 Then
      .MatchWholeWord = True
    Else
      .MatchWholeWord = False
    End If
    .Text = Split(xlFList, "|")(i)
    .Replacement.Text = "^&"
    .Execute Replace:=wdReplaceAll
  Next
Quote:
Originally Posted by Nicknamednick View Post
It also made many words bold that I would not have intended.
I can't see how the macro code could cause that. Perhaps your list is more expansive than you thought.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]