Aspose::Words::Fields::FieldOptions::get_TemplateName method

FieldOptions::get_TemplateName method

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

System::String Aspose::Words::Fields::FieldOptions::get_TemplateName() const

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.

auto doc = MakeObject<Document>();
auto builder = MakeObject<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->get_FieldOptions()->set_TemplateName(String::Empty);

auto field = System::ExplicitCast<FieldTemplate>(builder->InsertField(FieldType::FieldTemplate, false));
ASSERT_EQ(u" TEMPLATE ", field->GetFieldCode());

builder->Writeln();
field = System::ExplicitCast<FieldTemplate>(builder->InsertField(FieldType::FieldTemplate, false));
field->set_IncludeFullPath(true);

ASSERT_EQ(u" TEMPLATE  \\p", field->GetFieldCode());

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

See Also