DynamicTemplateState Object

SharePoint Designer Developer Reference

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

Remarks

The DynamicTemplateState object is an in-memory object and doesn't correspond to any Office SharePoint Designer 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.

Use the CreateDynamicTemplateState method of the Office SharePoint DesignerApplication object to create a new DynamicTemplateState object. The following example creates a new DynamicTemplateState object.

Visual Basic for Applications
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 Document 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. The example requires a Dynamic Web Template named "template.dwt" and a page named "home.htm" to work.

Visual Basic for Applications
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.

Visual Basic for Applications
Dim objState As DynamicTemplateState
Set objState = Application.CreateDynamicTemplateState
If ActiveDocument.DynamicTemplate <> "" Then _
    ActiveDocument.UpdateDynamicTemplate objState
End Sub

See Also