View Single Post
 
Old 05-08-2021, 02:37 PM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Replace paragraph with style and add an em dash

I have many instances in my document like

MESSAGE NOTES Luke 3:16
MESSAGE NOTES Luke 9:15-19
MESSAGE NOTES Luke 21:15-19

I would like to make two changes.
1) Change the style to "Book Title" and
2) Add an em dash in-between MESSAGE NOTES and the next word.

The examples above, all end with a paragraph mark.

Code:
Sub Replace_Me()
    With ActiveDocument.Range.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("Book Title")
        .Text = "MESSAGE NOTES Luke"
        .Replacement.Text = "^&"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Last edited by jeffreybrown; 05-08-2021 at 07:37 PM.
Reply With Quote