W
Word Heretic
(Reposted from Word PC mailing list)
Those of you who have been hanging around this list sucking down words
of wisdom from all and sundry will remember my list restart
breakthrough - the first macro to attach to a toolbar / shortcut to
restart your list numbering, irrespective of the list type. Of course,
this failed to work with XP's List Styles. Ordinary styles with list
properties - sure - but List Styles proper - nope.
Well, I had a brainstorm the other night. I think it was a brainstorm,
my head was buzzing with pain and water was leaking out if it
everywhere, maybe it was just the 'flu. Regardless, I have just tested
the concept and it WORKS muck ya.
I got lucky - Word XP actually bothers to include the New Object list
styles into the Old Object ListParagraphs. This is enough information
for the few wise asses to mangle the old code to come up with a
solution. However, I also bothered to demangle the old code to not use
an on error trap.
Everyone has permission to redistribute and use this code at will,
providing the (c) notice is left intact. In the interests of reducing
Worders Compensation cases, please DO post to any lists, friends and
so on that you have access to. Let's see if we cant make this one of
the fastest spams in town.
Public Sub RestartListNumbering(Optional Scope As Range)
'(c) 1999-2004 Word Heretic (e-mail address removed)
'Restarts list numbering, 97-XP, all list implementations
Dim KillScope As Boolean
If Scope Is Nothing Then
Set Scope = Selection.Range
KillScope = True
End If
'Use first listpara
With Scope.ListParagraphs
If .Count > 0 Then
With .Item(1).Range.ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End If
End With
'Destroy our objects
If KillScope Then Set Scope = Nothing
End Sub
Those of you who have been hanging around this list sucking down words
of wisdom from all and sundry will remember my list restart
breakthrough - the first macro to attach to a toolbar / shortcut to
restart your list numbering, irrespective of the list type. Of course,
this failed to work with XP's List Styles. Ordinary styles with list
properties - sure - but List Styles proper - nope.
Well, I had a brainstorm the other night. I think it was a brainstorm,
my head was buzzing with pain and water was leaking out if it
everywhere, maybe it was just the 'flu. Regardless, I have just tested
the concept and it WORKS muck ya.
I got lucky - Word XP actually bothers to include the New Object list
styles into the Old Object ListParagraphs. This is enough information
for the few wise asses to mangle the old code to come up with a
solution. However, I also bothered to demangle the old code to not use
an on error trap.
Everyone has permission to redistribute and use this code at will,
providing the (c) notice is left intact. In the interests of reducing
Worders Compensation cases, please DO post to any lists, friends and
so on that you have access to. Let's see if we cant make this one of
the fastest spams in town.
Public Sub RestartListNumbering(Optional Scope As Range)
'(c) 1999-2004 Word Heretic (e-mail address removed)
'Restarts list numbering, 97-XP, all list implementations
Dim KillScope As Boolean
If Scope Is Nothing Then
Set Scope = Selection.Range
KillScope = True
End If
'Use first listpara
With Scope.ListParagraphs
If .Count > 0 Then
With .Item(1).Range.ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End If
End With
'Destroy our objects
If KillScope Then Set Scope = Nothing
End Sub