Aspose::Words::Fields::FieldGoToButton::set_Location method
Contents
[
Hide
]FieldGoToButton::set_Location method
Sets the name of a bookmark, a page number, or some other item to jump to.
void Aspose::Words::Fields::FieldGoToButton::set_Location(const System::String & value)
Examples
Shows to insert a GOTOBUTTON field.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
auto field = System::ExplicitCast<Aspose::Words::Fields::FieldGoToButton>(builder->InsertField(FieldType::FieldGoToButton, true));
field->set_DisplayText(u"My Button");
field->set_Location(u"MyBookmark");
ASSERT_EQ(field->GetFieldCode(), u" GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder->InsertBreak(BreakType::PageBreak);
builder->StartBookmark(field->get_Location());
builder->Writeln(u"Bookmark text contents.");
builder->EndBookmark(field->get_Location());
doc->UpdateFields();
doc->Save(get_ArtifactsDir() + u"Field.GOTOBUTTON.docx");
See Also
- Class FieldGoToButton
- Namespace Aspose::Words::Fields
- Library Aspose.Words for C++