Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-30-2021, 07:28 PM
Guessed's Avatar
Guessed Guessed is offline Restarting Paragraph/Style Numbering on Each New Page of a Document Windows 10 Restarting Paragraph/Style Numbering on Each New Page of a Document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This would work but you might not like the global paragraph reset in the middle if you have paragraphs with local para formatting other than number resets.
Code:
Sub ToggleStyleNumbering2()
  Dim intResult As Integer, sFind As String, sReplace As String, iPage As Integer, aPar As Paragraph
  Dim aLT As ListTemplate
  
  intResult = MsgBox("Would you like to add numbering to Custom Style?" & vbCrLf & vbCrLf & _
        "Click 'Yes' to ADD or 'No' to REMOVE", vbYesNoCancel + vbQuestion, "Add or Remove Numbering")
  
  If intResult = vbYes Then    'Add Numbers
    sFind = "Normal"
    sReplace = "List Number"
  ElseIf intResult = vbNo Then    'Remove Numbers
    sFind = "List Number"
    sReplace = "Normal"
  Else
    Exit Sub
  End If

  With ActiveDocument.Content.Find
    .ClearFormatting
    .Style = ActiveDocument.Styles(sFind)
    .Replacement.Style = ActiveDocument.Styles(sReplace)
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
  End With
  
  ActiveDocument.Range.ParagraphFormat.Reset      'clears all paragraph format resets
  
  If sReplace = "List Number" Then
    Set aLT = ActiveDocument.Styles("List Number").ListTemplate
    For Each aPar In ActiveDocument.Range.Paragraphs
      If aPar.Style = "List Number" Then
        If aPar.Range.Information(wdActiveEndPageNumber) > iPage Then
          aPar.Range.ListFormat.ApplyListTemplate ListTemplate:=aPar.Range.ListFormat.ListTemplate, ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList
          iPage = aPar.Range.Information(wdActiveEndPageNumber)
        End If
      End If
    Next aPar
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restarting Paragraph/Style Numbering on Each New Page of a Document Restarting page numbering only if Section begins with Heading 1 kaurp Word VBA 5 11-02-2017 04:36 AM
How can I define a numbering style restarting numbering after an outline by default jklocker Word 1 09-26-2017 05:11 AM
Restarting Paragraph/Style Numbering on Each New Page of a Document RESTARTING page numbering in a sectioned document. jp91306 Word 3 01-01-2016 12:27 AM
Restarting Paragraph/Style Numbering on Each New Page of a Document Numbering not restarting at 1 between list styles cotjoey Word 11 09-21-2014 07:54 AM
Restarting Paragraph/Style Numbering on Each New Page of a Document reset numbering to 1 by paragraph Style Helix86 Word 5 08-07-2013 10:48 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:28 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