Share via


Template Object

Multiple objects
Template
Multiple objects

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

Using the Template Object

Use Templates(index), where index is the template name or the index number, to return a single Template object. The following example saves the Memo2.dot template if it's in the Templates collection.

For Each aTemp In Templates
    If LCase(aTemp.Name) = "memo2.dot" Then aTemp.Save
Next aTemp

The index number represents the position of the template in the Templates collection. The following example opens the first template in the Templates collection.

Templates(1).OpenAsDocument

The Add method isn't available for the Templates collection. Instead, you can add a template to the Templates collection by doing any of the following:

  • Using the Open method with the Documents collection to open a document based on a template or a template
  • Using the Add method with the Documents collection to open a new document based on a template
  • Using the Add method with the Addins collection to load a global template
  • Using the AttachedTemplate property with the Document object to attach a template to a document

Remarks

Use the NormalTemplate property to return a template object that refers to the Normal template. Use the AttachedTemplate property to return the template attached to the specified document.

Use the DefaultFilePath property to return or set the location of user or workgroup templates (that is, the folder where you want to store these templates). The following example displays the user template folder from the File Locations tab in the Options dialog box (Tools menu).

MsgBox Options.DefaultFilePath(wdUserTemplatesPath)

Properties | Application Property | AutoTextEntries Property | BuiltInDocumentProperties Property | Creator Property | CustomDocumentProperties Property | FarEastLineBreakLanguage Property | FarEastLineBreakLevel Property | FullName Property | JustificationMode Property | KerningByAlgorithm Property | LanguageID Property | LanguageIDFarEast Property | ListTemplates Property | Name Property | NoLineBreakAfter Property | NoLineBreakBefore Property | NoProofing Property | Parent Property | Path Property | Saved Property | Type Property | VBProject Property

Methods | OpenAsDocument Method | Save Method

Parent Objects | Application Object | Global Object

Child Objects | AutoTextEntries Object | ListTemplates Object

See Also | AddIn Object | Document Object