View Single Post
 
Old 08-08-2024, 08:21 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 Format manual numbering so auto numbering code can run

Hi Vivka, thanks for taking the time to update the code - unfortunately your code did not work for me, it threw up a few issues. I've posted a couple of images below.

Code not removing the very last at the end of levels 2-4 consistently
Capture1.JPG

Code separating text with a tab
Capture2JPG.JPG

I've added this to the beginning of the code which isn't ideal as it can't capture any other rogue punctuation without it affecting the rest of the document text e.g. instances at the end of paragraphs containing a semi colon (; and). Not as easy as I thought!!

Code:
Set rng = ActiveDocument.Range
    With rng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchWildcards = True
        .text = "([.])([ ])([A-Za-z])"
        .Replacement.text = "^t\3"
        .Execute Replace:=wdReplaceAll
    End With
Reply With Quote