Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 11-10-2023, 04:32 AM
gmaxey gmaxey is offline Apply style to next paragraph Windows 10 Apply style to next paragraph Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply a style to a group of words inside a paragraph? saint—112 Word 3 09-07-2022 09:55 PM
Apply table style shahid.majeed Word Tables 0 10-02-2019 01:25 AM
My style keeps changing, can't get saved style to apply Meenie50 Word 7 07-20-2017 03:47 PM
Paragraph space before - can styles apply it intelligently? timpani Word 7 10-23-2012 04:08 PM
Character style stripped while applying paragraph style sams_gates Word 0 08-29-2009 02:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft