Class ListTemplate (Word VBA)

The class ListTemplate represents a single list template that includes all the formatting that defines a list. The ListTemplate object is a member of the ListTemplates collection.

Set

To use a ListTemplate class variable it first needs to be instantiated, for example

Dim lte as ListTemplate
Set lte = ActiveDocument.ListTemplates(Index:=1)

The following procedures can be used to set variables of type ListTemplate: ListFormat.ListTemplate, Convert, ListTemplates.Add, ListTemplates.Item, Style.ListTemplate, Document.ListTemplates, ListGallery.ListTemplates and Template.ListTemplates

For Each

Here is an example of processing the ListTemplate items in a collection.

Dim lte As ListTemplate
For Each lte In ActiveDocument.ListTemplates
	
Next lte

Convert

Converts a multiple-level list to a single-level list, or vice versa.

You cannot use the Convert method on a list template that is derived from the ListGalleries collection.

Syntax : expression.Convert (Level)

Level: The level to use for formatting the new list. When converting a multiple-level list to a single-level list, this argument can be a number from 1 through 9. When converting a single-level list to a multiple-level list, 1 is the only valid value. If this argument is omitted, 1 is the default value.

ActiveDocument.ListTemplates(1).Convert

ListLevels

Returns a ListLevels collection that represents all the levels for the specified ListTemplate.

For information about returning a single member of a collection, see Returning an object from a collection.

Set myListTemp = _ 
 ListGalleries(wdOutlineNumberGallery).ListTemplates(1) 
For Each mylevel In myListTemp.ListLevels 
 mylevel.LinkedStyle = "Heading " & mylevel.index 
Next mylevel

Name

Returns or sets the name of the specified object.

ActiveDocument.ListTemplates(1).Name =

OutlineNumbered

True if the specified ListTemplate object is outline numbered.

Setting this property to False converts the list template to a single-level list that uses the formatting of the first level. You cannot set this property for a ListTemplate object returned from a ListGallery object.

Selection.Range.ListFormat.ListTemplate.OutlineNumbered = False

Parent

Returns an object that represents the parent object of the specified ListTemplate object.

Dim objParent As Object
Set objParent = ActiveDocument.ListTemplates(1).Parent

ListTemplates.Add

Returns a ListTemplate object that represents a new list template.

You cannot use the Add method on ListTemplates objects returned from a ListGallery object. You can, however, modify the existing list templates in the galleries.

Syntax : expression.Add (OutlineNumbered, Name)

Set myList = _ 
 ActiveDocument.ListTemplates.Add(OutlineNumbered:=False) 
myList.ListLevels(1).NumberStyle = wdListNumberStyleUpperCaseLetter 
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=myList

Arguments

The following arguments are optional

OutlineNumbered (Boolean) - True to apply outline numbering to the new list template.

Name (String) - An optional name used for linking the list template to a LISTNUM field. You can use this name to index the list template in the collection.

ListTemplates.Count

Returns a Long that represents the number of list templates in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.ListTemplates.Count

ListTemplates.Item

Returns an individual ListTemplate object in a collection.

Syntax : expression.Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.

Dim lte As ListTemplate
Set lte = ActiveDocument.ListTemplates(Index:=1)

ListTemplates.Parent

Returns an object that represents the parent object of the specified ListTemplates object.

Dim objParent As Object
Set objParent = ActiveDocument.ListTemplates.Parent