Aspose::Words::Fields::FieldKeywords::get_Text method
Contents
[
Hide
]FieldKeywords::get_Text method
Gets or sets the text of the keywords.
System::String Aspose::Words::Fields::FieldKeywords::get_Text()
Examples
Shows to insert a KEYWORDS field.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Add some keywords, also referred to as "tags" in File Explorer.
doc->get_BuiltInDocumentProperties()->set_Keywords(u"Keyword1, Keyword2");
// The KEYWORDS field displays the value of this property.
auto field = System::ExplicitCast<Aspose::Words::Fields::FieldKeywords>(builder->InsertField(FieldType::FieldKeyword, true));
field->Update();
ASSERT_EQ(field->GetFieldCode(), u" KEYWORDS ");
ASSERT_EQ(field->get_Result(), (u"Keyword1, Keyword2"));
// Setting a value for the field's Text property,
// and then updating the field will also overwrite the corresponding built-in property with the new value.
field->set_Text(u"OverridingKeyword");
field->Update();
ASSERT_EQ(field->GetFieldCode(), u" KEYWORDS OverridingKeyword");
ASSERT_EQ(field->get_Result(), u"OverridingKeyword");
ASSERT_EQ(doc->get_BuiltInDocumentProperties()->get_Keywords(), u"OverridingKeyword");
doc->Save(get_ArtifactsDir() + u"Field.KEYWORDS.docx");
See Also
- Class FieldKeywords
- Namespace Aspose::Words::Fields
- Library Aspose.Words for C++