Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #31  
Old 09-30-2024, 10:32 AM
gmaxey gmaxey 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 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Shelly, I ran the code I previously updated (posted here again) against your example and it produced the final correct result.
Code:
Option Explicit Private oRngNum As Range Sub FormatManualNumbering() Dim oRng As Range Dim oPar As Paragraph     Application.ScreenUpdating = False     Set oRng = ActiveDocument.Range     oRng.InsertBefore vbCr     With oRng.Find       .ClearFormatting       .Replacement.ClearFormatting       .Forward = True       .Wrap = wdFindStop       .Format = False       .MatchWildcards = False       'Remove spaces starting paras:       .Text = "^p^w"       .Replacement.Text = "^p"       .Execute Replace:=wdReplaceAll     End With     oRng.Characters(1).Delete     For Each oPar In oRng.Paragraphs       If IsNumeric(oPar.Range.Characters(1)) Then         Set oRngNum = oPar.Range         oRngNum.Collapse wdCollapseStart         Do Until oRngNum.Characters.Last.Next Like "[A-Za-z]"           oRngNum.MoveEnd wdCharacter, 1         Loop         ProcessNum       End If     Next    Application.ScreenUpdating = True lbl_Exit:   Exit Sub End Sub Sub ProcessNum() Dim oRng As Range Dim lngIndex As Long Dim bAllNums As Boolean   bAllNums = True   Set oRng = oRngNum.Duplicate   oRng.Collapse wdCollapseEnd   Do Until IsNumeric(oRng.Characters.First.Previous)     oRng.MoveStart wdCharacter, -1   Loop   oRng.Text = "." & vbTab   oRngNum.End = oRng.Start   For lngIndex = 1 To oRngNum.Characters.Count     If Not IsNumeric(oRngNum.Characters(lngIndex)) Then       If oRngNum.Characters(lngIndex) = " " And oRngNum.Characters(lngIndex).Previous = "." Then         oRngNum.Characters(lngIndex).Delete         lngIndex = lngIndex + 1       Else         oRngNum.Characters(lngIndex) = "."         bAllNums = False       End If     End If   Next   If Not bAllNums Then oRngNum.Characters.Last.Next.Delete lbl_Exit:   Exit Sub End Sub

Attached Files
File Type: docx 1 remove.docx (18.6 KB, 4 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
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 02:15 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