View Single Post
 
Old 04-01-2018, 06:15 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For that you could use code like:
Code:
Sub DemoII()
Application.ScreenUpdating = False
Dim RngSel As Range, RngTmp As Range, i As Long, j As Long
With Selection
  Set RngSel = .Range
  With .Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "\[list=[0-9]\]*\[/list\]"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found
      If .InRange(RngSel) = False Then Exit Do
      i = CLng(Split(Split(.Text, "]")(0), "=")(1)) - 1
      j = 0
      Set RngTmp = .Duplicate
      With .Duplicate
        .Paragraphs.First.Range.Text = vbNullString
        .Paragraphs.Last.Range.Text = vbNullString
        With .Find
          .ClearFormatting
          .Replacement.ClearFormatting
          .Text = "\[\*\]"
          .Replacement.Text = ""
          .Forward = True
          .Wrap = wdFindStop
          .Format = False
          .MatchWildcards = True
          .Execute
        End With
        Do While .Find.Found
          j = j + 1
          If .InRange(RngTmp) = False Then Exit Do
          .Text = i + j & ". "
          .Collapse wdCollapseEnd
          .Find.Execute
        Loop
      End With
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
End With
RngSel.Select
Set RngSel = Nothing:Set RngTmp = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote