模板对象 (Word)Template object (Word)

代表一个文档模板。Represents a document template. Template对象是**模板** 集合的成员。The Template object is a member of the Templates collection. 模板 集合包括所有可用的 模板 对象。The Templates collection includes all the available Template objects.

注解Remarks

使用模板(Index),其中 Index 是将模板名称或索引号,可返回单个Template对象。Use Templates (Index), where Index is the template name or the index number, to return a single Template object. 如果 模板 集合中,下面的示例保存 Memo2.dot 模板。The following example saves the Memo2.dot template if it is in the Templates collection.

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

索引号代表Templates集合中的模板的位置。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

不用于Templates集合的Add方法。The Add method is not available for the Templates collection. 相反,您可以将模板添加到 模板 集合通过执行下列任一操作︰Instead, you can add a template to the Templates collection by doing any of the following:

  • 使用Open方法和Documents集合打开基于模板或模板的文档Using the Open method with the Documents collection to open a document based on a template or a template

  • 使用Add方法和Documents集合打开基于模板的新文档Using the Add method with the Documents collection to open a new document based on a template

  • 使用Add方法和Addins集合加载共用模板Using the Add method with the Addins collection to load a global template

  • 使用AttachedTemplate属性与Document对象将模板附加到文档Using the AttachedTemplate property with the Document object to attach a template to a document

NormalTemplate属性用于返回 template 对象的引用 Normal 模板。Use the NormalTemplate property to return a template object that refers to the Normal template. 使用 AttachedTemplate 返回附加到指定文档的模板的属性。Use the AttachedTemplate property to return the template attached to the specified document.

使用DefaultFilePath属性可返回或设置用户或工作组模板 (即,要存储这些模板的文件夹) 的位置。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)

方法Methods

名称Name
OpenAsDocumentOpenAsDocument
SaveSave

属性Properties

名称Name
ApplicationApplication
BuildingBlockEntriesBuildingBlockEntries
BuildingBlockTypesBuildingBlockTypes
BuiltInDocumentPropertiesBuiltInDocumentProperties
CreatorCreator
CustomDocumentPropertiesCustomDocumentProperties
FarEastLineBreakLanguageFarEastLineBreakLanguage
FarEastLineBreakLevelFarEastLineBreakLevel
FullNameFullName
JustificationModeJustificationMode
KerningByAlgorithmKerningByAlgorithm
LanguageIDLanguageID
LanguageIDFarEastLanguageIDFarEast
ListTemplatesListTemplates
名称Name
NoLineBreakAfterNoLineBreakAfter
NoLineBreakBeforeNoLineBreakBefore
NoProofingNoProofing
ParentParent
PathPath
SavedSaved
类型Type
VBProjectVBProject

另请参阅See also

Word 对象模型参考Word Object Model Reference