ApplyListTemplate Method

Microsoft Word Visual Basic

Show All

ApplyListTemplate Method

       

 ApplyListTemplate method as it applies to the ListFormat object.

Applies a set of list-formatting characteristics to the specified ListFormat object

expression.ApplyListTemplate(ListTemplate, ContinuePreviousList, ApplyTo, DefaultListBehavior)

expression   Required. An expression that returns one of the above objects.

ListTemplate  Required ListTemplate object. The list template to be applied.

ContinuePreviousList  Optional Variant. True to continue the numbering from the previous list; False to start a new list.

ApplyTo  Optional Variant. The portion of the list that the list template is to be applied to. Can be one of the following WdListApplyTo constants: wdListApplyToSelection, wdListApplyToWholeList, or wdListApplyToThisPointForward.

DefaultListBehavior  Optional Variant. Sets a value that specifies whether Microsoft Word uses new Web-oriented formatting for better list display. Can be either of the following constants: wdWord8ListBehavior (use formatting compatible with Microsoft Word 97) or wdWord9ListBehavior (use Web-oriented formatting). For compatibility reasons, the default constant is wdWord8ListBehavior, but in new procedures you should use wdWord9ListBehavior to take advantage of improved Web-oriented formatting with respect to indenting and multilevel lists.

 

 ApplyListTemplate method as it applies to the List object.

Applies a set of list-formatting characteristics to the specified Listobject

expression.ApplyListTemplate(ListTemplate, ContinuePreviousList, DefaultListBehavior)

expression   Required. An expression that returns one of the above objects.

ListTemplate  Required ListTemplate object. The list template to be applied.

ContinuePreviousList  Optional Variant. True to continue the numbering from the previous list; False to start a new list.

DefaultListBehavior  Optional Variant. Sets a value that specifies whether Microsoft Word uses new Web-oriented formatting for better list display. Can be either of the following constants: wdWord8ListBehavior (use formatting compatible with Microsoft Word 97) or wdWord9ListBehavior (use Web-oriented formatting). For compatibility reasons, the default constant is wdWord8ListBehavior, but in new procedures you should use wdWord9ListBehavior to take advantage of improved Web-oriented formatting with respect to indenting and multilevel lists.

 

Example

As it applies to the ListFormat object.

This example sets the variable myRange to a range in the active document, and then it checks to see whether the range has list formatting. If no list formatting has been applied, the fourth outline-numbered list template is applied to the range.

Set myDoc = ActiveDocument
Set myRange = myDoc.Range( _
    Start:= myDoc.Paragraphs(3).Range.Start, _
    End:=myDoc.Paragraphs(6).Range.End)
If myRange.ListFormat.ListType = wdListNoNumbering Then
    myRange.ListFormat.ApplyListTemplate _
        ListTemplate:=ListGalleries(wdOutlineNumberGallery) _
        .ListTemplates(4)
End If

As it applies to the List object.

This example sets the variable myList to the fourth list in MyDocument.doc, and then it applies the third bulleted list template to the list.

Set myList = Documents("MyDocument.doc").Lists(4)
myList.ApplyListTemplate _
    ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(3)

This example sets the variable myLstRange to the list formatting in the second paragraph of MyDocument.doc. The example then applies the third numbered list template from that point forward in the list.

Set myLstRange = Documents("MyDocument.doc").Paragraphs(2) _
    .Range.ListFormat
myLstRange.ApplyListTemplate _
    ListTemplate:=ListGalleries(wdNumberGallery) _
    .ListTemplates(3), _
    ApplyTo:=wdListApplyToThisPointForward