Description
This class represents a hyperlink field in a document.
C#
public sealed class Hyperlink : Field
vb.net
Public NotInheritable Class Hyperlink Inherits Field
Remarks
To create a hyperlink, use Element.InsertHyperlinkBefore(). To get the hyperlinks in a Document, use the Element.GetElements() method with a Element.Type.Hyperlink parameter.
The following sample demonstrates creating a hyperlink at the end of a new document and retrieving the first hyperlink of an existing document.
Examples
C#
//--- Add a hyperlink to a document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Hyperlink link =
doc.InsertHyperlinkAfter("http://www.softartisans.com", "SoftArtisans");
//--- Get the first hyperlink from a document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Hyperlink firstLink =
doc.GetElements(Element.Type.Hyperlink)[0];
vb.net
'--- Add a hyperlink to a document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim link As Hyperlink = _
doc.InsertHyperlinkAfter("http://www.softartisans.com", "SoftArtisans")
'--- Get the first hyperlink from a document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim link As Hyperlink = _
doc.GetElements(Element.Type.Hyperlink)(0)
Methods
Name |
Description |
|---|---|
| Returns the URL that the hyperlink points to. |
