View Single Post
 
Old 09-25-2024, 02:53 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 Add brackets to sub level numbering

I have a little macro that adds an opening bracket to sub level numbering e.g a) becomes (a) or b. becomes (b) etc., but the issue I'm having is that it does not add an opening bracket for roman numerals ii, iii or iv but does add an opening bracket for i or v - what line of code can I add to include ii, iii, iv?

Add brackets to sub level definitions.docx

Code:
Sub DPU_TestDefinitions()
Dim oRng As Range, Para As Paragraph
With ActiveDocument
Set oRng = ActiveDocument.Range
  With oRng.Find
  .ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
  .MatchWildcards = True
     .text = "^13([A-Za-z0-9])\)"
     'make sure lists with unopened brackets a) get opening bracket and insert tab
     .Replacement.text = "^p(\1)"
     .Execute Replace:=wdReplaceAll
     .text = "^13([a-za-z0-9])\."
     'make sure lists with period a. get brackets and insert tab
     .Replacement.text = "^p(\1)"
     .Execute Replace:=wdReplaceAll
  End With
  End With
  End Sub
Reply With Quote