View Single Post
 
Old 02-18-2023, 10:33 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Given that you are attracted to autonumbering as suggested, the following macros will address that. The first replaces your numbered items with Sequence fields. The second will add a number using the same sequence and update the sequence to reflect the addition.
Code:
Sub ReplaceNumbers()
Dim oRng As Range
    ActiveWindow.ActivePane.View.ShowFieldCodes = True
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(findText:="\[[0-9]{1,}\]", _
                          MatchWildcards:=True, _
                          Wrap:=wdFindStop, _
                          Forward:=True) = True
            oRng.Fields.Add oRng, wdFieldSequence, "List\# ""'['0']'""", False
            oRng.Collapse 0
        Loop
    End With
    ActiveWindow.ActivePane.View.ShowFieldCodes = False
lbl_Exit:
Set oRng = Nothing
    Exit Sub
End Sub

Sub AddNumber()
Dim oRng As Range
Dim oField As Field
    ActiveWindow.ActivePane.View.ShowFieldCodes = True
    Set oRng = Selection.Range
    oRng.Fields.Add oRng, wdFieldSequence, "List\# ""'['0']'""", False
    oRng.Collapse 0
    ActiveWindow.ActivePane.View.ShowFieldCodes = False
    For Each oRng In ActiveDocument.StoryRanges
        For Each oField In oRng.Fields
            oField.Update
        Next oField
    Next oRng
lbl_Exit:
    Set oRng = Nothing
    Set oField = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote