View Single Post
 
Old 01-14-2022, 10:50 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Based on your example document:
Code:
Sub ChangeParasAfterHeading()
Dim para As Paragraph, nextPara As Paragraph
Dim oRng As Range
Dim i As Integer
    If Selection.Type = wdSelectionIP Then
        MsgBox Prompt:="You have not selected any text!"
        Exit Sub
    End If
    Set oRng = Selection.Range
    With oRng
        For Each para In oRng.Paragraphs
            For i = 1 To 7
                If para.Style Like "Heading " & i & "*" Then
                    Set nextPara = para.Next
                    If Not nextPara Is Nothing Then
                        If nextPara.Style = "Body Text" Then
                            nextPara.Style = "Body" & i
                        End If
                    End If
                End If
            Next i
        Next para
    End With
lbl_Exit:
    Set oPara = Nothing
    Set nextPara = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote