Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Word .NET
>
Tutorial
> Create hyperlink
The following example shows you how to add a hyperlink.
C# example
using System; using Independentsoft.Office.Word; namespace Sample { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument(); Run run = new Run(); run.AddText("Independentsoft"); run.Underline = new Underline(UnderlinePattern.Single); run.Color = new RunContentColor("#0000FF"); Hyperlink link = new Hyperlink(); link.Add(run); link.Target = "http://www.independentsoft.com"; Paragraph paragraph = new Paragraph(); paragraph.Add(link); doc.Body.Add(paragraph); doc.Save("c:\\test\\output.docx", true); } } }
VB example
Imports System Imports Independentsoft.Office.Word Module Module1 Sub Main(ByVal args() As String) Dim doc As WordDocument = New WordDocument() Dim run As Run = New Run() run.AddText("Independentsoft") run.Underline = New Underline(UnderlinePattern.Single) run.Color = New RunContentColor("#0000FF") Dim link As Hyperlink = New Hyperlink() link.Add(run) link.Target = "http://www.independentsoft.com" Dim paragraph As Paragraph = New Paragraph() paragraph.Add(link) doc.Body.Add(paragraph) doc.Save("c:\test\output.docx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*