View Single Post
 
Old 07-30-2019, 09:50 AM
WVA WVA is offline Windows 10 Office 2016
Novice
 
Join Date: Jul 2019
Posts: 4
WVA is on a distinguished road
Default

I've been using this same macro to try to change a style for the first sentence of each paragraph. However, because I have a ^13 wildcard in the find, the macro only works if the paragraph before is in the same style. I'd like for it to change the style for the first sentence of a paragraph but starting after the ^13.

Here is my macro so far:


Sub Demo()

Dim aRng As Range
Set aRng = ActiveDocument.Range

With aRng.Find
.ClearFormatting
.Text = "(^13)(*)(.)"
.MatchWildcards = True
.Style = ActiveDocument.Styles("Heading 2")
While .Execute
aRng.Start = aRng.Start + 1
aRng.End = aRng.End - 1
aRng.Style = ActiveDocument.Styles("Heading 2 Title Char")
aRng.Collapse wdCollapseEnd
Wend

End With

End Sub
Reply With Quote