Class Template (Word VBA)

The class Template represents a document template. The Template object is a member of the Templates collection. The Templates collection includes all the available Template objects.

The main procedure of class Template is OpenAsDocument

Set

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

Dim tmp as Template
Set tmp = CustomizationContext

The following procedures can be used to set variables of type Template: Application.CustomizationContext, Application.MacroContainer, Application.NormalTemplate, Document.AttachedTemplate, Templates.Item and Application.Templates

For Each

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

Dim tmp As Template
For Each tmp In Templates
	
Next tmp

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Name with its procedures FullName and Name

Methods

This is the main method of the Template class

OpenAsDocument - Opens the specified template as a document and returns a Document object.

Dim docOpenAsDocument As Document
Set docOpenAsDocument = CustomizationContext.OpenAsDocument()

Properties

AutoSaveOn

CustomizationContext.AutoSaveOn = True

BuildingBlockEntries returns a BuildingBlockEntries collection that represents the collection of building block entries in a template.

Dim bbesBuildingBlockEntries As BuildingBlockEntries
Set bbesBuildingBlockEntries = CustomizationContext.BuildingBlockEntries

BuildingBlockTypes returns a BuildingBlockTypes collection that represents the collection of building block types that are contained in a template.

Dim bbtsBuildingBlockTypes As BuildingBlockTypes
Set bbtsBuildingBlockTypes = CustomizationContext.BuildingBlockTypes

BuiltInDocumentProperties returns a DocumentProperties collection that represents all the built-in document properties for the specified document.

Dim dpsBuiltInDocumentProperties As DocumentProperties
dpsBuiltInDocumentProperties = CustomizationContext.BuiltInDocumentProperties

CustomDocumentProperties returns a DocumentProperties collection that represents all the custom document properties for the specified document.

Dim dpsCustomDocumentProperties As DocumentProperties
dpsCustomDocumentProperties = CustomizationContext.CustomDocumentProperties

FarEastLineBreakLanguage returns or sets the East Asian language to use when breaking lines of text in the specified document or template.

CustomizationContext.FarEastLineBreakLanguage = wdLineBreakJapanese

FarEastLineBreakLevel returns or sets the line break control level for the specified document.

CustomizationContext.FarEastLineBreakLevel = wdFarEastLineBreakLevelCustom

JustificationMode returns or sets the character spacing adjustment for the specified template.

CustomizationContext.JustificationMode = wdJustificationModeCompress

KerningByAlgorithm true if Microsoft Word kerns half-width Latin characters and punctuation marks in the specified document.

CustomizationContext.KerningByAlgorithm = True

LanguageID returns or sets a WdLanguageID constant that represents the language for the specified range.

CustomizationContext.LanguageID = wdAfrikaans

LanguageIDFarEast returns or sets an East Asian language for the specified object.

CustomizationContext.LanguageIDFarEast = wdAfrikaans

ListTemplates returns a ListTemplates collection that represents all the list formats for the specified template.

Dim ltsListTemplates As ListTemplates
Set ltsListTemplates = CustomizationContext.ListTemplates

NoLineBreakAfter returns or sets the kinsoku characters after which Microsoft Word will not break a line.

CustomizationContext.NoLineBreakAfter =

NoLineBreakBefore returns or sets the kinsoku characters before which Microsoft Word will not break a line.

CustomizationContext.NoLineBreakBefore =

NoProofing true if the spelling and grammar checker ignores documents based on this template.

CustomizationContext.NoProofing =

Parent returns an object that represents the parent object of the specified Template object.

Dim objParent As Object
Set objParent = CustomizationContext.Parent

Path returns the path to the specified document template.

Dim strPath As String
strPath = CustomizationContext.Path

Saved true if the specified template has not changed since it was last saved. False if Microsoft Word displays a prompt to save changes when the document is closed.

CustomizationContext.Saved = True

Type returns the template type.

Dim wttType As WdTemplateType
wttType = CustomizationContext.Type

VBProject returns the VBProject object for the specified template.

Dim vbpVBProject As VBIDE.VBProject
Set vbpVBProject = CustomizationContext.VBProject

Templates.Count returns a Long that represents the number of templates in the specified collection.

Dim lngCount As Long
lngCount = Templates.Count

Templates.Parent returns an object that represents the parent object of the specified Templates object.

Dim objParent As Object
Set objParent = Templates.Parent