![]() |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Figured it out with two macro. Since one of these macros uses FNR and the other does not, can they be combined or should they just stay separate?
Code:
Sub Replace_Me()
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Style = ActiveDocument.Styles("Book Title")
.Text = "^13MESSAGE NOTES[!^13]@^13"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End Sub
Code:
Sub Macro5()
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "DETAILED NOTES John"
.Replacement.Text = "MESSAGE NOTES ^+ Luke"
.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:36 PM. |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why does paragraph inherit style of the following paragraph? | WADEVCAMP | Word VBA | 2 | 04-08-2019 02:13 PM |
| Find/Replace adds a style to what I'm searching for AND the following paragraph | JFDI | Word | 2 | 03-27-2014 05:36 PM |
| Find bullets and replace with paragraph style? | cdybdahl | Word | 1 | 12-02-2011 02:14 AM |
Need Word to change -- (dash,dash) into one long dash.
|
Bobosmite | Word | 2 | 05-06-2011 04:21 AM |
| Character style stripped while applying paragraph style | sams_gates | Word | 0 | 08-29-2009 02:03 AM |