Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-05-2024, 02:37 AM
Shelley Lou Shelley Lou is offline VBA Format manual numbering so auto numbering code can run Windows 10 VBA Format manual numbering so auto numbering code can run Office 2016
Expert
VBA Format manual numbering so auto numbering code can run
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Format manual numbering so auto numbering code can run

When documents are converted from pdf to Word to be put into housestyle, the manual numbering can often be an issue. I am trying to put together a macro that will format the manual numbering to be 1. / 1.1 / 1.1.1 / 1.1.1.1 so that I can run my auto numbering macro without it running into errors.



For the first level manual numbering, the code needs to add a period if there isn't one already there (eg from 1 to be 1. otherwise the auto numbering macro won't work.

For the second, third and fourth level numbering (e.g. 1.1 or 1.1.1 or 1.1.1.1) I need the code to remove periods at the end of the manual numbering if they are present and that the periods between the manual numbering are in fact periods and not spaces, tabs, commas, semi-colons, colons etc.

I'm running into errors with my code below - can anyone help me fine tune the code. Thanks

format manual numbering before running auto numbering code.docx

Code:
Sub FormatManualNumbering()
Application.ScreenUpdating = False
   With ActiveDocument
  With .Range
    With .Find
  .ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = True
  .MatchWildcards = True
  .Replacement.ClearFormatting
  .text = "(^13)([0-9]@{1,})([ ^t])" 'insert period at end of manual numbering level 1 if there isn't one already there
  .Replacement.text = "\1\2.\3"
  .Execute Replace:=wdReplaceAll
    End With
    With .Find
    .ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = True
  .MatchWildcards = True
  .Replacement.ClearFormatting
  .text = "(^13)([0-9]@{1,}([.\,\:\;\ ])[0-9]{1,})([.])([ ^t])" 'insert period for manual numbering level 1.1 and remove period at end
  .Replacement.text = "\1\2.\"
  .Execute Replace:=wdReplaceAll
  .text = "(^13)([0-9]@{1,}([.\,\:\;\ ])[0-9]{1,}([.\,\:\;\ ])[0-9]{1,})([.])([ ^t])" 'insert period for manual numbering level 1.1.1 and remove period at end
  .Replacement.text = "\1\2.\3.\4"
  .Execute Replace:=wdReplaceAll
  .text = "(^13)([0-9]@{1,}([.\,\:\;\ ])[0-9]{1,}([.\,\:\;\ ])[0-9]{1,}([.\,\:\;\ ])[0-9]{1,})([.])([ ^t])" 'insert period for manual numbering level 1.1.1.1 and remove period at end
  .Replacement.text = "\1\2.\3.\4"
  .Execute Replace:=wdReplaceAll
  End With
     Application.ScreenUpdating = True
     End With
     End With
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Format manual numbering so auto numbering code can run VBA insert period after manual numbering Shelley Lou Word VBA 1 03-05-2023 03:45 AM
VBA Format manual numbering so auto numbering code can run VBA Remove manual numbering after Outline numbering Shelley Lou Word VBA 2 08-04-2021 12:24 AM
VBA Format manual numbering so auto numbering code can run VBA converting manual numbering to auto numbering Shelley Lou Word VBA 8 05-28-2021 01:08 AM
VBA Format manual numbering so auto numbering code can run Applying New Multi-Level List to Existing Document with Manual Numbering and Existing Styles stanley Word 4 12-15-2020 10:59 AM
page numbering for manual Bursal Word 1 07-29-2018 02:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:37 PM.


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