DynamicTemplateState Object

Microsoft FrontPage Visual Basic

DynamicTemplateState Object

DynamicTemplateState

Represents an object that stores mapping information related to a Dynamic Web Template.

Note  The DynamicTemplateState object is an in-memory object only and doesn't correspond to any Microsoft FrontPage application element or to an HTML element. Information about an attached Dynamic Web Template and associated regions within a document are stored in COMMENT elements within a document. Use the templateRegions property to access the Dynamic Web Template regions in a document.

Using the DynamicTemplateState object

Use the CreateDynamicTemplateState method of the FrontPage Application object to create a new DynamicTemplateState object. The following example creates a new DynamicTemplateState object.

    Dim objState As DynamicTemplateState

Set objState = Application.CreateDynamicTemplateState
  

Use the SetBodyMapping and SetHeadMapping methods to specify how to map regions in a document where the regions in a Dynamic Web Template are different from the existing regions in the document. Then use the ApplyDynamicTemplate method of the WebFile or FPHTMLDocument object to attach a Dynamic Web Template to a document.

The following example creates a new DynamicTemplateState object, specifies region mapping, and then attaches the specified Dynamic Web Template to the specified file.

    Dim objState As DynamicTemplateState
Dim objFile As WebFile

Set objState = Application.CreateDynamicTemplateState
Set objFile = ActiveWeb.LocateFile("home.htm")

objState.SetBodyMapping "", "template.dwt", "", "A1"
objState.SetHeadMapping "", "template.dwt", "", "metadata"

objFile.ApplyDynamicTemplate "template.dwt", objState
  

Use the UpdateDynamicTemplate method to update a page that is attached to a Dynamic Web Template to apply any changes that were made to the Dynamic Web Template file. The following example updates the Dynamic Web Template references in the active document.

    Dim objState As DynamicTemplateState

Set objState = Application.CreateDynamicTemplateState

If ActiveDocument.DynamicTemplate <> "" Then _
    ActiveDocument.UpdateDynamicTemplate objState

End Sub