此主题中的一些内容可能不适用于某些语言。
将现有 HTML 模板应用于当前站点。
expression.ApplyTemplate(TemplateDir, fApplyThemes, fOverWrite)
expression 必选。返回“应用于”列表中的对象之一的表达式。
TemplateDir 必选,String 类型。模板的路径。
fApplyThemes 可选。Boolean 类型。决定模板中的主题是否将应用于新站点。如果为 True,则主题将会应用于站点。如果为 False,则不会应用主题。默认值为 False。
fOverWrite 可选。Boolean 类型。决定是否覆盖当前模板。如果为 True,则当前模板将被覆盖。如果为 False,则不覆盖当前模板。默认值是 False。
下列示例使用 ApplyTemplate 方法将指定模板添加到当前站点。调用该方法时 fApplyThemes 参数和 fOverWrite 参数都设为 False。主题不会应用到新站点,并且任何现有的主题都不会覆盖。
Sub UseTemplate()
'Applies a template to the current web without overwriting the original template
'or applying themes.
Dim objApp As FrontPage.Application
Dim objWeb As WebEx
Dim strPath As String
Dim strname As String
Set objApp = FrontPage.Application
Set objWeb = objApp.ActiveWeb
'Set variable to template directory.
strPath = "C:\Program Files\Microsoft Office\Templates\"
'Prompt the user for the file name of the template
strname = InputBox("Enter the file name of the template you wish to apply")
'And the template name and directory to create a full path name
strPath = strPath & strname
'Apply the template to the new web
objWeb.ApplyTemplate TemplateDir:=strPath, _
fApplyThemes:=False, fOverWrite:=False
End Sub