![]() |
|
#5
|
||||
|
||||
|
This would work but you might not like the global paragraph reset in the middle if you have paragraphs with local para formatting other than number resets.
Code:
Sub ToggleStyleNumbering2()
Dim intResult As Integer, sFind As String, sReplace As String, iPage As Integer, aPar As Paragraph
Dim aLT As ListTemplate
intResult = MsgBox("Would you like to add numbering to Custom Style?" & vbCrLf & vbCrLf & _
"Click 'Yes' to ADD or 'No' to REMOVE", vbYesNoCancel + vbQuestion, "Add or Remove Numbering")
If intResult = vbYes Then 'Add Numbers
sFind = "Normal"
sReplace = "List Number"
ElseIf intResult = vbNo Then 'Remove Numbers
sFind = "List Number"
sReplace = "Normal"
Else
Exit Sub
End If
With ActiveDocument.Content.Find
.ClearFormatting
.Style = ActiveDocument.Styles(sFind)
.Replacement.Style = ActiveDocument.Styles(sReplace)
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
ActiveDocument.Range.ParagraphFormat.Reset 'clears all paragraph format resets
If sReplace = "List Number" Then
Set aLT = ActiveDocument.Styles("List Number").ListTemplate
For Each aPar In ActiveDocument.Range.Paragraphs
If aPar.Style = "List Number" Then
If aPar.Range.Information(wdActiveEndPageNumber) > iPage Then
aPar.Range.ListFormat.ApplyListTemplate ListTemplate:=aPar.Range.ListFormat.ListTemplate, ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList
iPage = aPar.Range.Information(wdActiveEndPageNumber)
End If
End If
Next aPar
End If
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Restarting page numbering only if Section begins with Heading 1
|
kaurp | Word VBA | 5 | 11-02-2017 04:36 AM |
| How can I define a numbering style restarting numbering after an outline by default | jklocker | Word | 1 | 09-26-2017 05:11 AM |
RESTARTING page numbering in a sectioned document.
|
jp91306 | Word | 3 | 01-01-2016 12:27 AM |
Numbering not restarting at 1 between list styles
|
cotjoey | Word | 11 | 09-21-2014 07:54 AM |
reset numbering to 1 by paragraph Style
|
Helix86 | Word | 5 | 08-07-2013 10:48 PM |