How to: Insert Bookmark or Hyperlink

  • 2 minutes to read

The following example demonstrates how to create a bookmark or hyperlink in the document.

To create a hyperlink, use the HyperlinkCollection.Create method. The newly created Hyperlink object will be automatically added to the document hyperlink collection, represented by the HyperlinkCollection instance.

Use the hyperlink's Hyperlink.NavigateUri property to set a target URI. To specify a text for the tooltip displayed when the mouse hovers over a hyperlink, use the Hyperlink.ToolTip property.

Create Bookmark

To create a bookmark, use the BookmarkCollection.Create method. It creates a Bookmark object with the specified name and range (or position) and adds it to the BookmarkCollection. Use the Document.Bookmark property to get access to the collection.

A bookmark can be referenced by a hyperlink. To do that, set the hyperlink's Hyperlink.Anchor property to the corresponding bookmark name, as in the code snippet below.