View Single Post
 
Old 05-27-2021, 07:08 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Expert
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA convert manual numbering to auto numbering in table

Ok, so I've used the second macro and modified it and it seems to work great. Is there a way of getting Definition Level 1 to restart to (a) when it is a new definition, it seems to work ok for the other levels but not for Def Level 1

Code:
Sub DPU_ApplyHeadingStylesTable()
Application.ScreenUpdating = False
Dim r As Long, i As Long
With ActiveDocument.Tables(1)
  For r = 1 To .Rows.Count
    With .Cell(r, 2).Range
      If .Characters.First <> "(" Then
        .Style = "DefText"
      Else
        i = Asc(Split(Split(.Text, "(")(1), ")")(0))
        Select Case i
          Case 97 To 104, 106 To 117, 119, 121 To 122: .Style = "Definition Level 1" 'LowercaseLetter
          Case 105, 118, 120: .Style = "Definition Level 2" 'LowercaseRoman
          Case 65 To 90: .Style = "Definition Level 3" 'UppercaseLetter
          Case 48 To 57: .Style = "Definition Level 4" 'Arabic
          
        End Select
        .Collapse wdCollapseStart
        .MoveEndUntil " "
        .End = .End + 1
        .Delete
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
Attached Files
File Type: docx Definition Test Doc.docx (21.0 KB, 14 views)
Reply With Quote