Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2024, 02:53 AM
Shelley Lou Shelley Lou is offline VBA Add brackets to sub level numbering Windows 10 VBA Add brackets to sub level numbering Office 2016
Expert
VBA Add brackets to sub level numbering
 
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
  #2  
Old 09-25-2024, 06:13 AM
macropod's Avatar
macropod macropod is offline VBA Add brackets to sub level numbering Windows 10 VBA Add brackets to sub level numbering Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

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]{1,})\)"
     'make sure lists with unopened brackets a) get opening bracket and insert tab
     .Replacement.text = "^p(\1)"
     .Execute Replace:=wdReplaceAll
     'make sure lists with period a. get brackets and insert tab
     .text = "^13([a-z0-9]{1,})."
     .Execute Replace:=wdReplaceAll
  End With
  End With
  End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-25-2024, 06:24 AM
Shelley Lou Shelley Lou is offline VBA Add brackets to sub level numbering Windows 10 VBA Add brackets to sub level numbering Office 2016
Expert
VBA Add brackets to sub level numbering
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Add brackets to sub level numbering

Thank you so much Macropod, not seen you on here for a while so really appreciate your response.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi level Caption numbering where second level starts a new number (not subset of previous number) Cosmo Word 4 11-17-2023 08:49 PM
Multilevel numbering - Two styles for the same level? TallTrees Word 9 07-29-2022 06:37 AM
VBA Add brackets to sub level numbering Multi-Level Clause Numbering - copy while retaining original numbering TonySpeels Word 2 08-17-2016 11:18 AM
VBA Add brackets to sub level numbering Word numbering (multi level) Matt_22 Word 1 04-07-2015 07:09 PM
VBA Add brackets to sub level numbering Heading level numbering in 2010 - wrong after second header level 1 taran Word 3 07-08-2013 01:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft