Restarting list numbering using a higher level style

S

Serban I. Minea

Hello all,



I have used the procedure named SetUpNumberedLists() and found on Margaret
Aldis's website. After copying the procedure's body from the web and paste
it "as is" in a new template project Module, I have run it and the results
were great.

After the procedure was completed, I have noticed that the document
(template in this case) had 4 ListTemplate objects and not only the one
added by the procedure. Running it step-by-step I have noticed that the
commands .LinkedStyle = ActiveDocument.Styles(...).NameLocal are
responsible for this "pirate" additions.

A question arise: How can I avoid this "extra" load on ListTemplate objects?



Thanks in advance
 
S

Serban I. Minea

Hi John,

Thank you for your explanation. It makes very much sense that some class
definitions of default list templates are instantiated when the style
associated by default to them is used, maybe just to fill up some data
structures in the style object.

My "problem" was only about control (as I apply it when I am writing my own
code) so I will take your advice: live with it.

Best regards,

Serban
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Serban:

You will notice that a List Template has a "Name" property. This is
mislabelled: it's not "The Name of the List Template", it's the "Name of the
ListNum fields sequence attached to this list template".

More importantly, it's not an index to the collection, so you cannot
retrieve a list template by the name attached to it.

However, when Margaret and Shauna and Bill Coan and I a few others were
playing around with this in the early days, we found we could attach a name
to the list template and it would stick.

We needed this in Word 97 and Word 2000, where the document would corrupt
and crash if the number of list templates got too high. Every time you
changed a list template or re-applied a style you would get a new list
template. In Word 2002 they put in a fix that would trim the number of list
templates in a document on Save, if the number was higher than 200. So now
we just ignore it. Call up the styles you want and just set the properties
of whichever list template is associated with each. If that creates some
extras, that won't matter until it gets above 200, when Word will
automatically trim them.

But here's some Word 97 code which shows how I worked around it:

' Define three List Template objects to contain our three lists
Dim HeadingList As ListTemplate
Dim NumberList As ListTemplate
Dim BulletList As ListTemplate

' When we enter this macro, we know we did not find the list
' template we were looking for, but we don't yet know if
' others do exist. This routine finds any that exist.

For i = 1 To ActiveDocument.ListTemplates.Count
Select Case ActiveDocument.ListTemplates(i).Name
Case Is = "OutlineHeadings"
Set HeadingList = ActiveDocument.ListTemplates(i)
Case Is = "OutlineNumbers"
Set NumberList = ActiveDocument.ListTemplates(i)
Case Is = "OutlineBullets"
Set BulletList = ActiveDocument.ListTemplates(i)
End Select
Next i

' Now we create any we did not find.
If HeadingList Is Nothing Then
Set HeadingList =
ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
HeadingList.Name = "OutlineHeadings"
End If
If NumberList Is Nothing Then
Set NumberList = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
NumberList.Name = "OutlineNumbers"
End If
If BulletList Is Nothing Then
Set BulletList = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
BulletList.Name = "OutlineBullets"
End If

Hope this helps


Hi John,

Thank you for your explanation. It makes very much sense that some class
definitions of default list templates are instantiated when the style
associated by default to them is used, maybe just to fill up some data
structures in the style object.

My "problem" was only about control (as I apply it when I am writing my own
code) so I will take your advice: live with it.

Best regards,

Serban

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top