Hyperlink

Hyperlink (7)

With linked images, you can direct users to a URL when they click the image. This article will show you how to create image hyperlinks in a Word document by using Spire.Doc.

Step 1: Create a Word document, add a section and a paragraph.

Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

Step 2: Load an image to a DocPicture object.

DocPicture picture = new DocPicture(doc);
picture.LoadImage(Image.FromFile("logo.png"));

Step 3: Add an image hyperlink to the paragraph.

paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink);

Step 4: Save the file.

doc.SaveToFile("output.docx", FileFormat.Docx);

Output:

Create an Image Hyperlink in Word in C#, VB.NET

Full Code:

[C#]
Document doc = new Document();
Section section = doc.AddSection();

Paragraph paragraph = section.AddParagraph();
Image image = Image.FromFile("logo.png");
DocPicture picture = new DocPicture(doc);
picture.LoadImage(image);
paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink);

doc.SaveToFile("output.docx", FileFormat.Docx);
[VB.NET]
Document doc = New Document()
Dim section As Section = doc.AddSection()

Dim paragraph As Paragraph = section.AddParagraph()
Dim image As Image = Image.FromFile("logo.png")
Dim picture As DocPicture = New DocPicture(doc)
picture.LoadImage(image)
paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink)
 
doc.SaveToFile("output.docx", FileFormat.Docx)

With the help of Spire.Doc, we can easily add the hyperlinks and edit the hyperlinks on the word document. This article will focus on demonstrate how to remove all the hyperlinks from the word document in C#.

Here comes to the details of how to remove the hyperlinks from the word document. Firstly, view the sample document with many hyperlinks:

How to remove the hyperlinks from the word document in C#

Step 1: Create a new word document and load the sample document from file:

Document doc = new Document();
doc.LoadFromFile("Sample.docx");

Step 2: Create a method FindAllHyperlinks() to get all the hyperlinks from the sample document.

private List FindAllHyperlinks(Document document)
 {
     List hyperlinks = new List();
     foreach (Section section in document.Sections)
     {
         foreach (DocumentObject sec in section.Body.ChildObjects)
         {
             if (sec.DocumentObjectType == DocumentObjectType.Paragraph)
             {
                 foreach (DocumentObject para in (sec as Paragraph).ChildObjects)
                 {
                     if (para.DocumentObjectType == DocumentObjectType.Field)
                     {
                         Field field = para as Field;

                         if (field.Type == FieldType.FieldHyperlink)
                         {
                             hyperlinks.Add(field);
                         }
                     }
                 }
             } 
         }
     }
     return hyperlinks;
 }

Step 3: Remove the font color and underline format of the hyperlinks.

private void FormatFieldResultText(Body ownerBody,int sepOwnerParaIndex,int endOwnerParaIndex,int sepIndex,int endIndex)
{
    for (int i = sepOwnerParaIndex; i <= endOwnerParaIndex; i++)
    {
        Paragraph para = ownerBody.ChildObjects[i] as Paragraph;
        if (i == sepOwnerParaIndex && i == endOwnerParaIndex)
        {
            for (int j = sepIndex + 1; j < endIndex; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
            
        }
        else if (i == sepOwnerParaIndex)
        {
            for (int j = sepIndex + 1; j < para .ChildObjects .Count ; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
        else if (i == endOwnerParaIndex)
        {
            for (int j = 0; j < endIndex; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
        else
        {
            for (int j = 0; j < para.ChildObjects.Count; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
    }
}
private void FormatText(TextRange tr)
{
    tr.CharacterFormat.TextColor = Color.Black;
    tr.CharacterFormat.UnderlineStyle = UnderlineStyle.None;
}

Step 4: Flatten the hyperlink field.

private void FlattenHyperlinks(Field field)
{
    int ownerParaIndex = field.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.OwnerParagraph);
    int fieldIndex = field.OwnerParagraph.ChildObjects.IndexOf(field);
    Paragraph sepOwnerPara = field.Separator.OwnerParagraph;
    int sepOwnerParaIndex = field.Separator.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.Separator.OwnerParagraph);
    int sepIndex = field.Separator.OwnerParagraph.ChildObjects.IndexOf(field.Separator);
    int endIndex = field.End.OwnerParagraph.ChildObjects.IndexOf(field.End);
    int endOwnerParaIndex = field.End.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.End.OwnerParagraph);

    FormatFieldResultText(field.Separator.OwnerParagraph.OwnerTextBody, sepOwnerParaIndex, endOwnerParaIndex, sepIndex, endIndex);

    field.End.OwnerParagraph.ChildObjects.RemoveAt(endIndex);

    for (int i = sepOwnerParaIndex; i >= ownerParaIndex; i--)
    {
        if (i == sepOwnerParaIndex && i == ownerParaIndex)
        {
            for (int j = sepIndex; j >= fieldIndex; j--)
            {
                field.OwnerParagraph.ChildObjects.RemoveAt(j);

            }
        }
        else if (i == ownerParaIndex)
        {
            for (int j = field.OwnerParagraph.ChildObjects.Count - 1; j >= fieldIndex; j--)
            {
                field.OwnerParagraph.ChildObjects.RemoveAt(j);
            }

        }
        else if (i == sepOwnerParaIndex)
        {
            for (int j = sepIndex; j >= 0; j--)
            {
                sepOwnerPara.ChildObjects.RemoveAt(j);
            }
        }
        else
        {
            field.OwnerParagraph.OwnerTextBody.ChildObjects.RemoveAt(i);
        }
    }
}

Step 5: Save the document to file.

doc.SaveToFile("removehyperlinks.docx", FileFormat.Docx);

Effective screenshot after remove the hyperlinks from the word document:

How to remove the hyperlinks from the word document in C#

Full codes of how to remove the hyperlinks from word document:

public Removehyperlink()
{
    Document doc = new Document();
    doc.LoadFromFile("Sample.docx");

    List hyperlinks = FindAllHyperlinks(doc);

    for (int i = hyperlinks.Count - 1; i >= 0; i--)
    {
        FlattenHyperlinks(hyperlinks[i]);
    }

    doc.SaveToFile("removehyperlinks.docx", FileFormat.Docx);

}
private List FindAllHyperlinks(Document document)
        {
            List hyperlinks = new List();
            foreach (Section section in document.Sections)
            {
                foreach (DocumentObject sec in section.Body.ChildObjects)
                {
                    if (sec.DocumentObjectType == DocumentObjectType.Paragraph)
                    {
                        foreach (DocumentObject para in (sec as Paragraph).ChildObjects)
                        {
                            if (para.DocumentObjectType == DocumentObjectType.Field)
                            {
                                Field field = para as Field;

                                if (field.Type == FieldType.FieldHyperlink)
                                {
                                    hyperlinks.Add(field);
                                }
                            }
                        }
                    }
                }
            }
            return hyperlinks;
        }

private void FlattenHyperlinks(Field field)
{
    int ownerParaIndex = field.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.OwnerParagraph);
    int fieldIndex = field.OwnerParagraph.ChildObjects.IndexOf(field);
    Paragraph sepOwnerPara = field.Separator.OwnerParagraph;
    int sepOwnerParaIndex = field.Separator.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.Separator.OwnerParagraph);
    int sepIndex = field.Separator.OwnerParagraph.ChildObjects.IndexOf(field.Separator);
    int endIndex = field.End.OwnerParagraph.ChildObjects.IndexOf(field.End);
    int endOwnerParaIndex = field.End.OwnerParagraph.OwnerTextBody.ChildObjects.IndexOf(field.End.OwnerParagraph);

    FormatFieldResultText(field.Separator.OwnerParagraph.OwnerTextBody, sepOwnerParaIndex, endOwnerParaIndex, sepIndex, endIndex);

    field.End.OwnerParagraph.ChildObjects.RemoveAt(endIndex);

    for (int i = sepOwnerParaIndex; i >= ownerParaIndex; i--)
    {
        if (i == sepOwnerParaIndex && i == ownerParaIndex)
        {
            for (int j = sepIndex; j >= fieldIndex; j--)
            {
                field.OwnerParagraph.ChildObjects.RemoveAt(j);

            }
        }
        else if (i == ownerParaIndex)
        {
            for (int j = field.OwnerParagraph.ChildObjects.Count - 1; j >= fieldIndex; j--)
            {
                field.OwnerParagraph.ChildObjects.RemoveAt(j);
            }

        }
        else if (i == sepOwnerParaIndex)
        {
            for (int j = sepIndex; j >= 0; j--)
            {
                sepOwnerPara.ChildObjects.RemoveAt(j);
            }
        }
        else
        {
            field.OwnerParagraph.OwnerTextBody.ChildObjects.RemoveAt(i);
        }
    }
}

private void FormatFieldResultText(Body ownerBody, int sepOwnerParaIndex, int endOwnerParaIndex, int sepIndex, int endIndex)
{
    for (int i = sepOwnerParaIndex; i <= endOwnerParaIndex; i++)
    {
        Paragraph para = ownerBody.ChildObjects[i] as Paragraph;
        if (i == sepOwnerParaIndex && i == endOwnerParaIndex)
        {
            for (int j = sepIndex + 1; j < endIndex; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }

        }
        else if (i == sepOwnerParaIndex)
        {
            for (int j = sepIndex + 1; j < para.ChildObjects.Count; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
        else if (i == endOwnerParaIndex)
        {
            for (int j = 0; j < endIndex; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
        else
        {
            for (int j = 0; j < para.ChildObjects.Count; j++)
            {
                FormatText(para.ChildObjects[j] as TextRange);
            }
        }
    }
}
private void FormatText(TextRange tr)
{
    tr.CharacterFormat.TextColor = Color.Black;
    tr.CharacterFormat.UnderlineStyle = UnderlineStyle.None;
}

By default, hyperlink in Word shows up as blue and underlined. In some cases, users may want to modify the hyperlink style so as to get better looking with the whole document. This article is going to introduce how we can remove the underline or change the color of hyperlinks using Spire.Doc in C#.

Code Snippets:

Step 1: Create a new object of Document class, add a section to it.

Document document = new Document();
Section section = document.AddSection();

Step 2: Add a paragraph and append a hyperlink to the paragraph. In order to format the hyperlink, we return the value of hyperlink in a TextRange.

Paragraph para= section.AddParagraph();
TextRange txtRange = para1.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);

Step 3: Format the hyperlink with the specified the font name, font size, color and underline style.

txtRange.CharacterFormat.FontName = "Times New Roman";
txtRange.CharacterFormat.FontSize = 12;
txtRange.CharacterFormat.TextColor = System.Drawing.Color.Red;
txtRange.CharacterFormat.UnderlineStyle = UnderlineStyle.None;

Step 4: Save the file.

document.SaveToFile("result.docx", FileFormat.Docx2013);

Output:

How to change the color or remove underline from hyperlink in Word with C#

Full Code:

using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace FormatHyperlink
{
    class Program
    {
        static void Main(string[] args)
        {
            Document document = new Document();
            Section section = document.AddSection();

            Paragraph para1= section.AddParagraph();
            para1.AppendText("Regular Link: ");
            TextRange txtRange1 = para1.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
            txtRange1.CharacterFormat.FontName = "Times New Roman";
            txtRange1.CharacterFormat.FontSize = 12;
            Paragraph blankPara1 = section.AddParagraph();

            Paragraph para2 = section.AddParagraph();
            para2.AppendText("Change Color: ");
            TextRange txtRange2 = para2.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
            txtRange2.CharacterFormat.FontName = "Times New Roman";
            txtRange2.CharacterFormat.FontSize = 12;
            txtRange2.CharacterFormat.TextColor = System.Drawing.Color.Red;
            Paragraph blankPara2 = section.AddParagraph();

            Paragraph para3 = section.AddParagraph();
            para3.AppendText("Remove Underline: ");
            TextRange txtRange3 = para3.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
            txtRange3.CharacterFormat.FontName = "Times New Roman";
            txtRange3.CharacterFormat.FontSize = 12;
            txtRange3.CharacterFormat.UnderlineStyle = UnderlineStyle.None;

            document.SaveToFile("result.docx", FileFormat.Docx2013);
            System.Diagnostics.Process.Start("result.docx");
        }
    }
}
Friday, 27 June 2014 08:50

How to Modify Hypertext in Word Document

Written by support iceblue

Hyperlinks have two basic parts: the address (URL) of a certain object and the display text. As an essential element in electronic document, hyperlinks are frequently used in Word to redirect to large amount of information without occupying much space. However, Word doesn't always get the hyperlink correct. In this article, I'll introduce you how to change the displayed text of a hyperlink in C# via Spire.Doc for .NET.

Here is a Word document that makes a brief introduction about Spire.Doc, but as you can see from the picture below, the first hyperlink has been embedded with a wrong text description.

Modify Hyperlinks in Word Document

Now, we are able to change the hypertext as "Spire.Doc component" by using the following method.

Step 1: Create a new instance of Word document and load the sample file.

Document document = new Document();
document.LoadFromFile("..\\..\\Spire.Doc.docx");

Step 2: Call FindAllHyperlinks() method to find all hyperlinks in the Word document.

static List FindAllHyperlinks(Document document)
        {
            List hyperlinks = new List();
            foreach (Section section in document.Sections)
            {
                foreach (DocumentObject sec in section.Body.ChildObjects)
                {
                    if (sec.DocumentObjectType == DocumentObjectType.Paragraph)
                    {
                        foreach (DocumentObject para in (sec as Paragraph).ChildObjects)
                        {
                            if (para.DocumentObjectType == DocumentObjectType.Field)
                            {
                                Field field = para as Field;

                                if (field.Type == FieldType.FieldHyperlink)
                                {
                                    hyperlinks.Add(field);
                                }
                            }
                        }
                    }
                }
            }

Step 3: Reset the property of hyperlinks[0].FieldText by using the index of the hyperlink.

hyperlinks[0].FieldText = "Spire.Doc component";

string outfile="result.doc";
document.SaveToFile(outfile,FileFormat.Doc);
System.Diagnostics.Process.Start(outfile);

Result:

Modify Hyperlinks in Word Document

Thursday, 26 June 2014 06:42

Finding Hyperlinks in a word document in C#

Written by support iceblue

Hyperlinks can point to files, emails, websites, imagers or video when readers click on it. Hyperlinks are widely used in word document for it is very convenient to direct readers to related, useful content. By using Spire.Doc, developers can add hyperlinks, finding hyperlinks and modify hyperlinks. This article will show you how to find all the existing hyperlinks in a word document in C#.

Download and install Spire.Doc for .NET and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll". Here comes to the details of how to finding hyperlinks in C#.

Firstly, view the word document which contains many hyperlinks:

Finding Hyperlinks in a word document

Please check the code of how to find all the hyperlinks in word document:

static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("Spire.docx");
            List<Field> hyperlinks = new List<Field>();
            foreach (Section section in doc.Sections)
            {
                foreach (DocumentObject sec in section.Body.ChildObjects)
                {
                    if (sec.DocumentObjectType == DocumentObjectType.Paragraph)
                    {
                        foreach (DocumentObject para in (sec as Paragraph).ChildObjects)
                        {
                            if (para.DocumentObjectType == DocumentObjectType.Field)
                            {
                                Field field = para as Field;

                                if (field.Type == FieldType.FieldHyperlink)
                                {
                                    hyperlinks.Add(field);
                                }
                            }
                        }
                    }
                }
            }

The effective screenshot of the finding hyperlinks:

Finding Hyperlinks in a word document

Tuesday, 11 September 2012 02:26

Insert Word Hyperlink in Silverlight

Written by support iceblue

Word hyperlink can guide users to get other related information to contents. It can be Email address, website link or even other documents. When inserting hyperlink, users can add for specified text or enter link address directly.

Spire.Doc for Silverlight, a powerful component on manipulating Word documents with Silverlight, enables users to insert hyperlink in Word with Silverlight. This guide will show the method to realize inserting word hyperlinks in Silverlight. Users can invoke paragraph.AppendHyperlink(link string, text string, hyperlink type) method which is provided by Spire.Doc for Silverlight directly to insert hyperlink in Word.

Download Spire.Doc for Silverlight. Create a Silverlight application. Add a button in MainPage.xaml, and then double it to use the following code to insert hyperlink.

The following screenshot demonstrates the result after inserting hyperlink to Word in Silverlight. The hyperlink is located at the bottom of the picture.

Insert Word Hyperlink

Sample code:

[C#]
using System;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using System.Reflection;
using Spire.Doc;
using Spire.Doc.Documents;

namespace InsertHyperlink
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Declare SaveFileDialog
            SaveFileDialog save = new SaveFileDialog();
            save.Filter = "Word Document(*.docx)|*.docx";

            //Load Document
            Document document = new Document();
            Assembly assembly = this.GetType().Assembly;
            foreach (String name in assembly.GetManifestResourceNames())
            {
                if (name.EndsWith("Spire.Doc for Silverlight.docx"))
                {
                    using (Stream docStream = assembly.GetManifestResourceStream(name))
                    {
                        document = new Document(docStream, FileFormat.Docx);
                    }
                }
            }

            //Add Hyperlink
            Section section = document.Sections[0];
            Paragraph LinkPara = section.AddParagraph();
            LinkPara.AppendHyperlink("http://www.e-iceblue.com/Introduce/word-for-silverlight-introduce.html", "Learn More about Spire.Doc for Siverlight", HyperlinkType.WebLink);

            //Set Paragrah Style
            ParagraphStyle style = new ParagraphStyle(document);
            style.Name = "LinkStyle";
            style.CharacterFormat.FontName = "Britannic Bold";
            style.CharacterFormat.FontSize = 13;
            style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
            style.ParagraphFormat.LineSpacing = 15F;
            document.Styles.Add(style);
            LinkPara.ApplyStyle(style.Name);

            //Save Document
            bool? result = save.ShowDialog();
            if (result.HasValue && result.Value)
            {
                using (Stream stream = save.OpenFile())
                {
                    document.SaveToStream(stream, FileFormat.Docx);
                }
            }  
        }
    }
}
[VB.NET]
Imports System.IO
Imports System.Reflection
Imports System.Drawing
Imports Spire.Doc
Imports Spire.Doc.Documents

Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        'Declare SaveFileDialog
        Dim save As New SaveFileDialog()
        save.Filter = "Word Document(*.docx)|*.docx"

        'Load Document
        Dim document As New Document()
        Dim [assembly] As System.Reflection.Assembly = Me.GetType().Assembly
        For Each name As String In [assembly].GetManifestResourceNames()
            If name.EndsWith("Spire.Doc for Silverlight.docx") Then
                Using docStream As Stream = [assembly].GetManifestResourceStream(name)
                    document = New Document(docStream, FileFormat.Docx)
                End Using
            End If
        Next name

        'Add Hyperlink
        Dim section As Section = document.Sections(0)
        Dim LinkPara As Paragraph = section.AddParagraph()
        LinkPara.AppendHyperlink("http://www.e-iceblue.com/Introduce/word-for-silverlight-introduce.html", "Learn More about Spire.Doc for Siverlight", HyperlinkType.WebLink)

        'Set Paragrah Style
        Dim style As New ParagraphStyle(document)
        style.Name = "LinkStyle"
        style.CharacterFormat.FontName = "Britannic Bold"
        style.CharacterFormat.FontSize = 13
        style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple
        style.ParagraphFormat.LineSpacing = 15.0F
        document.Styles.Add(style)
        LinkPara.ApplyStyle(style.Name)

        'Save Document
        Dim result? As Boolean = save.ShowDialog()
        If result.HasValue AndAlso result.Value Then
            Using stream As Stream = save.OpenFile()
                document.SaveToStream(stream, FileFormat.Docx)
            End Using
        End If
    End Sub
End Class

Spire.Doc is an Microsoft Word component which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF.NET and Silverlight.

Friday, 07 January 2011 07:10

Insert Hyperlink to Word in C#, VB.NET

Written by Administrator

Word Hyperlink can be inserted automatically when users press ENTER or SPACEBAR after typing address of an existing Web page, such as www.e-iceblue.com. Also, users can insert customized hyperlink in Word for text to picture that they want to display as hyperlink. The hyperlink for text or picture can be Web page, E-mail address, other files or document.

Spire.Doc for .NET, a professional .NET Word component to manipulate Word documents, enables users to insert hyperlink in Word with C#/VB.NET. You can invoke the method paragraph.AppendHyperlink(string link, string text, HyperlinkType) to insert hyperlink in Word directly via Spire.Doc for .NET. And the HyperlinkType in method can be set as WebLink, EmailLink etc. Below is an effective screenshot after inserting hyperlink to Word in C#, VB.NET

Insert Word Hyperlink

Download and install Spire.Doc for .NET and then use the following code to insert hyperlink in Word.

[C#]
            //Create Word
            Document document = new Document();
            Section section = document.AddSection();
            Paragraph paragraph = section.AddParagraph();

            //Set Paragraph Styles
            ParagraphStyle txtStyle = new ParagraphStyle(document);
            txtStyle.Name = "Style";
            txtStyle.CharacterFormat.FontName = "Impact";
            txtStyle.CharacterFormat.FontSize = 16;
            txtStyle.CharacterFormat.TextColor = Color.RosyBrown;
            document.Styles.Add(txtStyle);

            ParagraphStyle hyperlinkstyle = new ParagraphStyle(document);
            hyperlinkstyle.Name = "linkStyle";
            hyperlinkstyle.CharacterFormat.FontName = "Calibri";
            hyperlinkstyle.CharacterFormat.FontSize = 15;
            document.Styles.Add(hyperlinkstyle);

            //Append Text and Set Text Format
            paragraph = section.AddParagraph();
            paragraph.AppendText("Home page");
            paragraph.ApplyStyle(txtStyle.Name);

            //Insert Hyperlink(Web Page)
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
            paragraph.ApplyStyle(hyperlinkstyle.Name);

            //Append text
            paragraph = section.AddParagraph();
            paragraph.AppendText("Contact US");
            paragraph.ApplyStyle(txtStyle.Name);

            //Insert Hyperlink(E-mail Address);
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-iceblue.com", HyperlinkType.EMailLink);
            paragraph.ApplyStyle(hyperlinkstyle.Name);

            //Save and Launch
            document.SaveToFile("Hyperlink.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("Hyperlink.docx");
[VB.NET]
           'Create Word
            Dim document As New Document()
            Dim section As Section = document.AddSection()
            Dim paragraph As Paragraph = section.AddParagraph()

            'Set Paragraph Styles
            Dim txtStyle As New ParagraphStyle(document)
            txtStyle.Name = "Style"
            txtStyle.CharacterFormat.FontName = "Impact"
            txtStyle.CharacterFormat.FontSize = 16
            txtStyle.CharacterFormat.TextColor = Color.RosyBrown
            document.Styles.Add(txtStyle)

            Dim hyperlinkstyle As New ParagraphStyle(document)
            hyperlinkstyle.Name = "linkStyle"
            hyperlinkstyle.CharacterFormat.FontName = "Calibri"
            hyperlinkstyle.CharacterFormat.FontSize = 15
            document.Styles.Add(hyperlinkstyle)

            'Append Text and Set Text Format
            paragraph = section.AddParagraph()
            paragraph.AppendText("Home page")
            paragraph.ApplyStyle(txtStyle.Name)

            'Insert Hyperlink(Web Page)
            paragraph = section.AddParagraph()
            paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink)
            paragraph.ApplyStyle(hyperlinkstyle.Name)

            'Append text
            paragraph = section.AddParagraph()
            paragraph.AppendText("Contact US")
            paragraph.ApplyStyle(txtStyle.Name)

            'Insert Hyperlink(E-mail Address);
            paragraph = section.AddParagraph()
            paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-iceblue.com", HyperlinkType.EMailLink)
            paragraph.ApplyStyle(hyperlinkstyle.Name)

            'Save and Launch
            document.SaveToFile("Hyperlink.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("Hyperlink.docx")

Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.