Aspose::Words::Fields::FieldQuote::set_Text method

FieldQuote::set_Text method

Sets the text to retrieve.

void Aspose::Words::Fields::FieldQuote::set_Text(const System::String & value)

Examples

Shows to use the QUOTE field.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Insert a QUOTE field, which will display the value of its Text property.
auto field = System::ExplicitCast<Aspose::Words::Fields::FieldQuote>(builder->InsertField(FieldType::FieldQuote, true));
field->set_Text(u"\"Quoted text\"");

ASSERT_EQ(field->GetFieldCode(), u" QUOTE  \"\\\"Quoted text\\\"\"");

// Insert a QUOTE field and nest a DATE field inside it.
// DATE fields update their value to the current date every time we open the document using Microsoft Word.
// Nesting the DATE field inside the QUOTE field like this will freeze its value
// to the date when we created the document.
builder->Write(u"\nDocument creation date: ");
field = System::ExplicitCast<Aspose::Words::Fields::FieldQuote>(builder->InsertField(FieldType::FieldQuote, true));
builder->MoveTo(field->get_Separator());
builder->InsertField(FieldType::FieldDate, true);

ASSERT_EQ(field->GetFieldCode(), System::String(u" QUOTE \u0013 DATE \u0014") + System::DateTime::get_Now().get_Date().ToShortDateString() + u"\u0015");

// Update all the fields to display their correct results.
doc->UpdateFields();

ASSERT_EQ(doc->get_Range()->get_Fields()->idx_get(0)->get_Result(), u"\"Quoted text\"");

doc->Save(get_ArtifactsDir() + u"Field.QUOTE.docx");

See Also