![]() |
#16
|
||||
|
||||
![]()
Try:
Code:
Sub ApplyHeadingStyles_Auto() 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 With Rng .Collapse wdCollapseStart .MoveEndUntil " ", wdForward If InStr(.Text, vbTab) > 0 Then .Collapse wdCollapseStart .MoveEndUntil vbtab, wdForward End If StrTxt = .Text: bLvl = False .End = .End + 1 End With objUndo.StartCustomRecord ("Fmt") For i = 1 To 6 .Style = "Heading " & i If .Range.ListFormat.ListString = StrTxt Then Rng.Text = vbNullString bLvl = True: Exit For End If Next objUndo.EndCustomRecord If bLvl = False Then ActiveDocument.Undo End With Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Last Chance | Word | 3 | 06-09-2021 12:52 PM |
Using numbered list style, how to indent text immediately following heading to match heading indent? | SpechtacularDave | Word | 3 | 09-25-2019 01:22 PM |
Heading not following the correct numbering | jongleur | Word | 2 | 05-16-2017 10:52 AM |
![]() |
Jennifer Murphy | Word VBA | 2 | 12-14-2015 02:31 AM |
![]() |
KieranWood | Word | 2 | 03-03-2011 09:28 AM |