# Shape Hyperlink

DsWord is a Document Solutions product that offers a high performance library to create, load, modify, and save Word documents programmatically.

## Content

Providing hyperlinks in a shape makes it convenient to navigate to the required information. DsWord enables you to use or define hyperlink actions when hovering or clicking on the hyperlink using [HyperlinkOnAction](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.html) class and **HyperlinkOnClick** and **HyperlinkOnHover** properties of Shape classes such as [Shape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shape.html), [Picture](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Picture.html), [GroupShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.GroupShape.html), [CanvasShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.CanvasShape.html), and [InkShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.InkShape.html), which are derived from [ShapeBase](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeBase.html).
HyperlinkOnAction class provides [Address](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.Address.html), [Action](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.Action.html), [HighlightClick](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.HighlightClick.html), [Viewed](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.Viewed.html), [Target](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.Target.html), [InvalidUrl](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.InvalidUrl.html), and [ScreenTip](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.ScreenTip.html) properties that enable you to set various hyperlink properties when you hover over it or click on it. These properties also allow you to use the **Edit Link**, **Open Link**, and **Remove Link** options in Microsoft Word.
Refer to the following example code to define HyperlinkOnAction and use it in the shape's hyperlink:

```csharp
static void Main(string[] args)
{
    // Initialize GcWordDocument.
    var doc = new GcWordDocument();

    // Add picture to document.
    var image = doc.Body.Paragraphs.Add().AddRun().AddPicture();

    // Set picture width and height.
    image.Size.Width.Value = 500f;
    image.Size.Height.Value = 500f;

    // Set poster frame image.
    byte[] imageBytes1 = File.ReadAllBytes("sunrise.jpg");
    image.ImageData.SetImage(imageBytes1, contentType: "image/jpg");

    // Set click and hover actions for hyperlink.
    SetHyperlinkOnAction(image.HyperlinkOnClick);
    SetHyperlinkOnAction(image.HyperlinkOnHover);

    // Save the document.
    doc.Save("ShapeHyperlink.docx");
}

// Define HyperlinkOnAction.
static void SetHyperlinkOnAction(HyperlinkOnAction ha)
{
    var url = "https://www.youtube.com/watch?v=gsnqXt7d1mU&list=PL4Gr5tOAPttLOY9IrWVjJlv4CtkYI5cI_&index=2";
    ha.Address = new Uri(url);
    ha.Action = "action";
    ha.HighlightClick = true;
    ha.Viewed = true;
    ha.Target = "target";
    ha.InvalidUrl = "invalid url";
    ha.ScreenTip = "screen tip";
}
```

**![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/hyperlink-on-action.png)**
**Limitations**

* DsWord does not parse Sound element of HyperlinkOnClick and HyperlinkOnHover classes present in OpenXml specification.
* Microsoft Word does not display the hyperlink context menu options (Edit Link, Open Link, Remove Link) for InkShape.