Template 对象 (Word)Template object (Word)

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

备注Remarks

使用模板(索引), 其中索引是模板名称或索引号, 返回单个模板对象。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

Add方法不适用于Templates集合。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属性可返回一个代表 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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.