View Single Post
 
Old 06-20-2021, 04:00 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Dec 2020
Posts: 170
Shelley Lou is on a distinguished road
Default VBA Find and Replace for sub levels

Hi, I'm looking to update the code below. It needs to insert a tab at the beginning of sentences for sub-levels which it currently does as it stands at the moment. I want the macro to also convert any instances of a single bracket sub level e.g. a), i), A), 1) to (a), (i), (A), (1) but I can't seem to fathom how to do this. Can anyone help at all? Thanks

Sub Level Test Doc.docx


Code:
Set orng = ActiveDocument.Range
 'insert tab at beginning of paragraph with a bracket e.g. (a), a), (i), i), (1), 1)
  With orng.Find
        .MatchWildcards = True
        .Text = "^13(\([a-z0-9]{1,}\))"
        .Replacement.Text = "^p^t\1"
        .Execute Replace:=wdReplaceAll
    End With
Reply With Quote