TemplateName

FieldOptions.TemplateName property

Gets or sets the file name of the template used by the document.

public string TemplateName { get; set; }

Remarks

This property is used by the FieldTemplate field if the AttachedTemplate property is empty.

If this property is empty, the default template file name Normal.dotm is used.

Examples

Shows how to use a TEMPLATE field to display the local file system location of a document’s template.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// We can set a template name using by the fields. This property is used when the "doc.AttachedTemplate" is empty.
// If this property is empty the default template file name "Normal.dotm" is used.
doc.FieldOptions.TemplateName = string.Empty;

FieldTemplate field = (FieldTemplate)builder.InsertField(FieldType.FieldTemplate, false);
Assert.AreEqual(" TEMPLATE ", field.GetFieldCode());

builder.Writeln();
field = (FieldTemplate)builder.InsertField(FieldType.FieldTemplate, false);
field.IncludeFullPath = true;

Assert.AreEqual(" TEMPLATE  \\p", field.GetFieldCode());

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.TEMPLATE.docx");

See Also