Microsoft Word 2017 VBA Troubleshooting Restart Numbering Macro

Jan 24, 2018
Reaction score
I would like to restart numbering using a macro, but I would like it to be able to not restart numbering when it precedes the Numbering All-in One Paragraph style. Note, this document is installed into a template. When I run the code below, it just restarts numbering any time there is a different style after it. Please help!!!

Sub RestartLists()
' Restarts all lists where the previous paragraph is not the numbering style.
' It starts from the current cursor location.
' You should run ContinueListsFast first to reset all the numbering.
' Edward Chan 2017

Dim listName As String
Dim myPara As Paragraph
Dim boolRestart As Boolean

' Set bookmark for return.
ActiveDocument.Bookmarks.Add Name:="WhereYouWere", Range:=Selection.Range

' ListName for the style of the list.
listName = "Sub Para List"
' Pass one: Change all first occurrences to 1.

Selection.Find.Style = ActiveDocument.Styles(listName)

While Selection.Find.Found
Set myPara = Selection.Paragraphs(1)
If myPara.Previous.Style Is Nothing Then myParaName = " " Else myParaName = myPara.Previous.Style ' get around strange string comparison bug when the style is empty
If myParaName <> listName Then
' Need to click the "Restart Numbering" button. It's the only way to reset numbering reliably.
' See
' See

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Application.Run MacroName:="RestartNumbering"
End If

' Now set the second item to continue to resolve Word bug

If Selection.Range.Listformat.ListValue = 2 And Selection.Range.Listformat.ListLevelNumber = 1 Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Application.Run MacroName:="ContinueNumbering"
End If
Selection.GoTo What:=wdGoToBookmark, Name:="WhereYouWere"
Selection.GoTo What:=wdGoToBookmark, Name:="WhereYouWere"
End Sub

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question