View Single Post
 
Old 11-10-2023, 04:32 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,441
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

RobiNew,


I doubt that would make a difference. The most likely problem is that you find yourself at the end of the document and there is no .Next paragraph to apply the style to.


When you post, instead of "I get an error" How about I get the following error Err.Number and Err.Description.


Try:


Code:
Sub A()
  Dim oPar As Paragraph
  For Each oPar In ActiveDocument.Paragraphs
    If oPar.Range.ParagraphFormat.Alignment = wdAlignParagraphRight Then
      oPar.Style = "MyStyle1"
      If Not oPar.Range.End = ActiveDocument.Range.End Then
        oPar.Next.Style = "MyStyle2" '---> I get an error
      End If
    'End If
  Next oPar
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote