ApplyTemplate Method

Microsoft FrontPage Visual Basic

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 site.

expression.ApplyTemplate(TemplateDir, fOverWrite)

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

TemplateDir   Required String. The path of the template.

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 site 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 site and any existing template will not be overwritten.

    Sub UseTemplate()
			'Applies a template to the current Web site 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")

    'Add the template name to the path in order to 
				'create a full path name.
    strPath = strPath & strname

    'Apply the template to the new Web site.
    objWeb.ApplyTemplate TemplateDir:=strPath, _
        fOverWrite:=False

End Sub