ApplyTemplate Method

       

Some of the content in this topic may not be applicable to some languages.

Applies an existing HTML template to the current web.

expression.ApplyTemplate(TemplateDir, fApplyThemes, fOverWrite)

expression   Required. An expression that returns one of the objects in the Applies To list.

TemplateDir  Required String. The path of the template.

fApplyThemes  Optional. A Boolean that determines if the themes in the template will be applied to the new web. If True, the themes will be applied to the web. If False, the themes will not be applied. The default value is False.

fOverWrite  Optional. A  Boolean that determines if the current template will be overwritten. If True, the current template will be overwritten. If False, the current template will not be overwritten. The default value is False.

Example

The following example adds a specified template to the current web using the ApplyTemplate method. The method is called with the fApplyThemes and the fOverWrite arguments set to False. The themes will not be applied to the new web and any existing template will not be overwritten.

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