![]() |
#1
|
|||
|
|||
![]()
Hi, just following on from Shelley Lou's post with Macropod and others re autonumbering different styled documents.
I attach BEFORE doc and AFTER doc. In the after doc the macro ceases at 3.7 Test for some reason. I tried making the heading longer but it didn't make a difference. I have been using the macro below from Macropod: Code:
Sub ApplyHeadingStyles_Auto1Works1() Application.ScreenUpdating = False Dim Para As Paragraph, Rng As Range, i As Long, StrTxt As String, bLvl As Boolean Dim objUndo As UndoRecord: Set objUndo = Application.UndoRecord With ActiveDocument.Range For Each Para In .Paragraphs With Para Set Rng = .Range.Characters.First With Rng If .text Like "[0-9(]" Then .MoveEndUntil " ", wdForward If InStr(.text, vbTab) > 0 Then .Collapse wdCollapseStart .MoveEndUntil vbTab, wdForward End If StrTxt = .text: bLvl = False .End = .End + 1 objUndo.StartCustomRecord ("Fmt") For i = 1 To 6 .Style = "Heading " & i If .ListFormat.ListString = StrTxt Then .text = vbNullString: bLvl = True: Exit For End If Next objUndo.EndCustomRecord If bLvl = False Then ActiveDocument.Undo: DoEvents End If End With End With Next End With Application.ScreenUpdating = True End Sub |
#2
|
||||
|
||||
![]()
It stops working at 3.7 because your document doesn't have a 3.6 heading before it. The preceding heading is 3.5. The (very elegant) code is comparing the expected numbers with the hard coded numbers and if the pattern a match is not identified then it leaves it as is.
Once the expected numbers are broken, it won't start working again until you get to the next parent Heading level.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Thank you Guessed.
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does Word have Autonumber Format (like in FrameMaker)? | Luxanais | Word | 7 | 05-19-2015 12:57 AM |
![]() |
Lpitt56 | Word | 1 | 09-22-2011 04:04 PM |
need autonumber in my excel file | mit | Excel | 2 | 06-21-2011 10:56 PM |
Match numbered list formatting b/w documents? | sbranecki | Word | 0 | 09-10-2009 03:12 PM |
Reversed Printing of Numbers in Numbered Documents | HCM1962 | Word | 0 | 09-22-2008 10:39 AM |