Insert Hyperlink to Word in C#, VB.NET

Word Hyperlink can be inserted automatically when users press ENTER or SPACEBAR after typing address of an existing Web page, such as 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.

            //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;

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

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

            //Insert Hyperlink(Web Page)
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("", "", HyperlinkType.WebLink);

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

            //Insert Hyperlink(E-mail Address);
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("", "", HyperlinkType.EMailLink);

            //Save and Launch
            document.SaveToFile("Hyperlink.docx", FileFormat.Docx);
           '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

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

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

            'Insert Hyperlink(Web Page)
            paragraph = section.AddParagraph()
            paragraph.AppendHyperlink("", "", HyperlinkType.WebLink)

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

            'Insert Hyperlink(E-mail Address);
            paragraph = section.AddParagraph()
            paragraph.AppendHyperlink("", "", HyperlinkType.EMailLink)

            'Save and Launch
            document.SaveToFile("Hyperlink.docx", FileFormat.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.