Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 09-28-2022, 05:41 PM
macropod's Avatar
macropod macropod is offline Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence Windows 10 Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence 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]
 

Tags
excel 2019, ms-word, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence Wildcards: searching for multiple words / expressions close to each other ballpoint Word VBA 7 11-09-2017 03:30 PM
Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence Best Practice for Indexing Multiple Word Terms and Sub-Terms jhy001 Word 4 11-06-2017 02:08 PM
Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence All words in document appear bold but are not! Ezra Word 4 07-31-2017 06:53 AM
Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence Making Multiple Words Bold mtk989 Word 2 06-25-2011 11:27 AM
Searching a Word document with multiple words from a list (over 1,000 terms) and BOLD all occurrence How to make a list of all the bold words in a document? galaxy_110 Word 1 12-31-2010 08:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:33 AM.


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