FieldHyperlink class

Implements the HYPERLINK field To learn more, visit the Working with Fields documentation article.

Remarks

When selected, causes control to jump to the location such as a bookmark or a URL.

Inheritance: FieldHyperlinkField

Constructors

NameDescription
FieldHyperlink()The default constructor.

Properties

NameDescription
addressGets or sets a location where this hyperlink jumps.
display_resultGets the text that represents the displayed field result.
(Inherited from Field)
endGets the node that represents the field end.
(Inherited from Field)
formatGets a FieldFormat object that provides typed access to field’s formatting.
(Inherited from Field)
is_dirtyGets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field)
is_image_mapGets or sets whether to append coordinates to the hyperlink for a server-side image map.
is_lockedGets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field)
locale_idGets or sets the LCID of the field.
(Inherited from Field)
open_in_new_windowGets or sets whether to open the destination site in a new web browser window.
resultGets or sets text that is between the field separator and field end.
(Inherited from Field)
screen_tipGets or sets the ScreenTip text for the hyperlink.
separatorGets the node that represents the field separator. Can be None.
(Inherited from Field)
startGets the node that represents the start of the field.
(Inherited from Field)
sub_addressGets or sets a location in the file, such as a bookmark, where this hyperlink jumps.
targetGets or sets the target to which the link should be redirected.
typeGets the Microsoft Word field type.
(Inherited from Field)

Methods

NameDescription
get_field_code()Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
(Inherited from Field)
get_field_code(include_child_field_codes)Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field)
remove()Removes the field from the document. Returns a node right after the field. If the field’s end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns None.
(Inherited from Field)
unlink()Performs the field unlink.
(Inherited from Field)
update()Performs the field update. Throws if the field is being updated already.
(Inherited from Field)
update(ignore_merge_format)Performs a field update. Throws if the field is being updated already.
(Inherited from Field)

Examples

Shows how to use HYPERLINK fields to link to documents in the local file system.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

field = builder.insert_field(aw.fields.FieldType.FIELD_HYPERLINK, True).as_field_hyperlink()

# When we click this HYPERLINK field in Microsoft Word,
# it will open the linked document and then place the cursor at the specified bookmark.
field.address = MY_DIR + "Bookmarks.docx"
field.sub_address = "MyBookmark3"
field.screen_tip = "Open " + field.address + " on bookmark " + field.sub_address + " in a new window"

builder.writeln()

# When we click this HYPERLINK field in Microsoft Word,
# it will open the linked document, and automatically scroll down to the specified iframe.
field = builder.insert_field(aw.fields.FieldType.FIELD_HYPERLINK, True).as_field_hyperlink()
field.address = MY_DIR + "Iframes.html"
field.screen_tip = "Open " + field.address
field.target = "iframe_3"
field.open_in_new_window = True
field.is_image_map = False

doc.update_fields()
doc.save(ARTIFACTS_DIR + "Field.field_hyperlink.docx")

See Also