View Single Post
 
Old 11-10-2023, 02:11 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default Apply style to next paragraph

I'm trying to apply a style to the next paragraph after changing the preceding one, but I get an error. Can someone help? Thanks!
Code:
Dim oPar As Paragraph
 For Each oPar In ActiveDocument.Paragraphs
    If oPar.Range.ParagraphFormat.Alignment = wdAlignParagraphRight Then
      oPar.Range.Style = "MyStyle1"
'      oPar.Next.Style = "MyStyle2" '---> I get an error
    End If
Next oPar
Reply With Quote