View Single Post
 
Old 05-28-2022, 03:27 PM
Frogoogue Frogoogue is offline Windows 10 Office 2019
Novice
 
Join Date: May 2022
Posts: 3
Frogoogue is on a distinguished road
Default How to code a Find&Replace macro to remove a tab and bold the entire para

I have a Word document with interviewer questions and answers
The format is like this:
<Interviewer:><^t><One or more sentence(s) with closing punctuation><^p>
and I want an MS Word Find and Replace macro to convert each instance into this:
<bold><Interviewer:><space><Identical One or more sentence(s) with closing punctuation><^p></bold>

The macro routine would look something like this:

Sub Reformat_Tabbed_Para()
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Bold = True
With Selection.Find
.Text = <><><><>
.Replacement.Text = "\1[space]\3\4"

.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

I believe there is code allowing me to find and replace the same string of characters and punctuation up to the ^p but cannot find the correct way of writing it.
Help would be much appreciated!
Reply With Quote