![]() |
|
#1
|
|||
|
|||
|
I would like to replace some keywords using wildcards, while also capturing the wildcard group and applying bold formatting to the matches. I have two codes so far, but neither one accomplishes both requirements.
The first code captures the group but does not set the bold formatting: Code:
With Selection.Find
.Text = "(wildcard_pattern_here)"
.Replacement.Text = "original text: \1"
.Replacement.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Code:
With Selection.Find
.Text = "(wildcard_pattern_here)"
.Replacement.Text = "original text: \1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
Selection.Font.Bold = True
Selection.TypeText Text:=.Replacement.Text
Loop
End With
Thank you! Alex |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wildcard find/replace wildcard question | hephalumph | Word | 1 | 03-12-2022 12:54 AM |
| wildcard search and add (not replace) sequential numbers in front | equalizer88 | Word VBA | 4 | 05-07-2016 08:04 PM |
Find/Replace Wildcard Needed-Bold & Highlight
|
rsrasc | Word VBA | 3 | 11-11-2014 03:55 PM |
| Issue with Wildcard Search and Replace | linusthedog | Word | 3 | 09-04-2014 03:32 PM |
| how to search and replace BOLD text >> font color change? | dylansmith | Word | 4 | 03-12-2013 09:51 PM |