SlideShare a Scribd company logo
1 of 4
How to Use C#/VB.NET Add Hyperlink in Word

Why Add Hyperlink in Word?

Hyperlink is an element in an electronic document that links to another place in the same
document or to an entirely different document. Typically, you click on the hyperlink to follow the
link. Hyperlinks are the most essential ingredient of all hypertext systems, including the World
Wide Web. And Microsoft Word is the most popular program for us to design and edit content.
Add hyperlink in Word can easily link to other place by simply press “Ctrl” and right click.

In Microsoft Word, it’s easy to add hyperlink. Select the text or picture that you want to display as
the hyperlink. On the Insert tab, in the Links group, click Hyperlink. To link to an existing file or
Web page, click Existing File or Web Page under Link to, and then type the address that you want
to link to in the Address box. If you don't know the address for a file, click the arrow in the Look
in list, and then navigate to the file that you want.

On the other hand, by using C#/VB.NET, you also can add hyperlink in Word and you are not
necessary to install Microsoft Office in your system.

How to Use C# Add Hyperlink in Word

Spire.Doc is a Word Component which enables user to perform a wide range of Word document
processing tasks directly for .NET and Silverlight which presents a simply way to use Word
hyperlink, including add hyperlink in Word.

Download Spire.Doc (or Spire.Office which includes Spire.Doc) with .NET framework together.

Suppose we have written a word document which we want to add hyperlinks. We can use
paragraph.AppendHyperlink method to insert hyperlinks. In paragraph.AppendHyperlink method
we give it three parameters. The first one is the text of the hyperlink, the second is the address of
the hyperlink and the last is the format of the hyperlink.

C# add hyperlinks in word:

01   using Spire.Doc;
02   using Spire.Doc.Documents;
03
04   namespace Hyperlink
05   {
06     class Program
07     {
08        static void Main(string[] args)
09        {
10           //Create word document
11           Document document = new Document();
12
13           //Create section
14           Section section = document.AddSection();
15
16           //Add paragraph
17           Paragraph paragraph = section.AddParagraph();
18
19           //Append text
20            paragraph.AppendText("Spire.XLS for .NET rn e-iceblue company Ltd. 2002-2010
All rights reserverd");
21           paragraph.ApplyStyle(BuiltinStyle.Heading2);
22           paragraph = section.AddParagraph();
23           paragraph.AppendText("Home page");
24           paragraph.ApplyStyle(BuiltinStyle.Heading2);
25
26           //Add paragraph
27           paragraph = section.AddParagraph();
28
29           //Insert a weblink
30                      paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com",
HyperlinkType.WebLink);
31
32           //Append text
33           paragraph = section.AddParagraph();
34           paragraph.AppendText("Contact US");
35           paragraph.ApplyStyle(BuiltinStyle.Heading2);
36
37           //Add paragraph
38           paragraph = section.AddParagraph();
39
40           //Insert an Emaillink
41                     paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-
iceblue.com", HyperlinkType.EMailLink);
42
43           //Save the file.
44           document.SaveToFile("Sample.doc", FileFormat.Doc);
45
46           //Launching the file.
47           System.Diagnostics.Process.Start("Sample.doc");
48         }
49      }
50 }
How to Use VB.NET Add Hyperlink in Word

01 Imports Spire.Doc
02 Imports Spire.Doc.Documents
03
04 Module Module1
05
06     Sub Main()
07       'Create word document
08       Dim document As New Document()
09
10       'Create section
11       Dim section As Section = document.AddSection()
12
13       'Add paragraph
14       Dim paragraph As Paragraph = section.AddParagraph()
15
16       'Append text
17         paragraph.AppendText("Spire.XLS for .NET " & vbCrLf & " e-iceblue company Ltd.
2002-2010 All rights reserverd")
18       paragraph.ApplyStyle(BuiltinStyle.Heading2)
19       paragraph = section.AddParagraph()
20       paragraph.AppendText("Home page")
21       paragraph.ApplyStyle(BuiltinStyle.Heading2)
22
23       'Add paragraph
24       paragraph = section.AddParagraph()
25
26       'Insert a weblink
27                    paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com",
HyperlinkType.WebLink)
28
29       'Add paragraph
30       paragraph = section.AddParagraph()
31
32       'Append text
33       paragraph.AppendText("Contact US")
34       paragraph.ApplyStyle(BuiltinStyle.Heading2)
35
36       'Add paragraph
37       paragraph = section.AddParagraph()
38
39       'Insert an Emaillink
40                   paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-
iceblue.com", HyperlinkType.EMailLink)
41
42        'Save the file.
43        document.SaveToFile("Sample.doc")
44
45        'Launch the file.
46        System.Diagnostics.Process.Start("Sample.doc")
47     End Sub
48 End Module



Screenshot after running the code above:




More about Spire.Doc
Download Spire.Doc
Purchase Spire.Doc

More Related Content

More from Chen Stephen

A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2Chen Stephen
 
How to prevent code rot
How to prevent code rotHow to prevent code rot
How to prevent code rotChen Stephen
 
5 ui tips for web apps
5 ui tips for web apps5 ui tips for web apps
5 ui tips for web appsChen Stephen
 
A developer's first impressions for windows 8
A developer's first impressions for windows 8A developer's first impressions for windows 8
A developer's first impressions for windows 8Chen Stephen
 
C# excel set excel number style
C# excel   set excel number styleC# excel   set excel number style
C# excel set excel number styleChen Stephen
 
C# excel bar chart
C# excel bar chartC# excel bar chart
C# excel bar chartChen Stephen
 
C# insert comments in word
C# insert comments in wordC# insert comments in word
C# insert comments in wordChen Stephen
 

More from Chen Stephen (8)

A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2
 
How to prevent code rot
How to prevent code rotHow to prevent code rot
How to prevent code rot
 
5 ui tips for web apps
5 ui tips for web apps5 ui tips for web apps
5 ui tips for web apps
 
A developer's first impressions for windows 8
A developer's first impressions for windows 8A developer's first impressions for windows 8
A developer's first impressions for windows 8
 
C# excel set excel number style
C# excel   set excel number styleC# excel   set excel number style
C# excel set excel number style
 
C# excel bar chart
C# excel bar chartC# excel bar chart
C# excel bar chart
 
C# insert comments in word
C# insert comments in wordC# insert comments in word
C# insert comments in word
 
Listview to dif
Listview to difListview to dif
Listview to dif
 

Recently uploaded

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Recently uploaded (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

How to use c#vb.net add hyperlink into word

  • 1. How to Use C#/VB.NET Add Hyperlink in Word Why Add Hyperlink in Word? Hyperlink is an element in an electronic document that links to another place in the same document or to an entirely different document. Typically, you click on the hyperlink to follow the link. Hyperlinks are the most essential ingredient of all hypertext systems, including the World Wide Web. And Microsoft Word is the most popular program for us to design and edit content. Add hyperlink in Word can easily link to other place by simply press “Ctrl” and right click. In Microsoft Word, it’s easy to add hyperlink. Select the text or picture that you want to display as the hyperlink. On the Insert tab, in the Links group, click Hyperlink. To link to an existing file or Web page, click Existing File or Web Page under Link to, and then type the address that you want to link to in the Address box. If you don't know the address for a file, click the arrow in the Look in list, and then navigate to the file that you want. On the other hand, by using C#/VB.NET, you also can add hyperlink in Word and you are not necessary to install Microsoft Office in your system. How to Use C# Add Hyperlink in Word Spire.Doc is a Word Component which enables user to perform a wide range of Word document processing tasks directly for .NET and Silverlight which presents a simply way to use Word hyperlink, including add hyperlink in Word. Download Spire.Doc (or Spire.Office which includes Spire.Doc) with .NET framework together. Suppose we have written a word document which we want to add hyperlinks. We can use paragraph.AppendHyperlink method to insert hyperlinks. In paragraph.AppendHyperlink method we give it three parameters. The first one is the text of the hyperlink, the second is the address of the hyperlink and the last is the format of the hyperlink. C# add hyperlinks in word: 01 using Spire.Doc; 02 using Spire.Doc.Documents; 03 04 namespace Hyperlink 05 { 06 class Program 07 { 08 static void Main(string[] args) 09 { 10 //Create word document
  • 2. 11 Document document = new Document(); 12 13 //Create section 14 Section section = document.AddSection(); 15 16 //Add paragraph 17 Paragraph paragraph = section.AddParagraph(); 18 19 //Append text 20 paragraph.AppendText("Spire.XLS for .NET rn e-iceblue company Ltd. 2002-2010 All rights reserverd"); 21 paragraph.ApplyStyle(BuiltinStyle.Heading2); 22 paragraph = section.AddParagraph(); 23 paragraph.AppendText("Home page"); 24 paragraph.ApplyStyle(BuiltinStyle.Heading2); 25 26 //Add paragraph 27 paragraph = section.AddParagraph(); 28 29 //Insert a weblink 30 paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink); 31 32 //Append text 33 paragraph = section.AddParagraph(); 34 paragraph.AppendText("Contact US"); 35 paragraph.ApplyStyle(BuiltinStyle.Heading2); 36 37 //Add paragraph 38 paragraph = section.AddParagraph(); 39 40 //Insert an Emaillink 41 paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e- iceblue.com", HyperlinkType.EMailLink); 42 43 //Save the file. 44 document.SaveToFile("Sample.doc", FileFormat.Doc); 45 46 //Launching the file. 47 System.Diagnostics.Process.Start("Sample.doc"); 48 } 49 } 50 }
  • 3. How to Use VB.NET Add Hyperlink in Word 01 Imports Spire.Doc 02 Imports Spire.Doc.Documents 03 04 Module Module1 05 06 Sub Main() 07 'Create word document 08 Dim document As New Document() 09 10 'Create section 11 Dim section As Section = document.AddSection() 12 13 'Add paragraph 14 Dim paragraph As Paragraph = section.AddParagraph() 15 16 'Append text 17 paragraph.AppendText("Spire.XLS for .NET " & vbCrLf & " e-iceblue company Ltd. 2002-2010 All rights reserverd") 18 paragraph.ApplyStyle(BuiltinStyle.Heading2) 19 paragraph = section.AddParagraph() 20 paragraph.AppendText("Home page") 21 paragraph.ApplyStyle(BuiltinStyle.Heading2) 22 23 'Add paragraph 24 paragraph = section.AddParagraph() 25 26 'Insert a weblink 27 paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink) 28 29 'Add paragraph 30 paragraph = section.AddParagraph() 31 32 'Append text 33 paragraph.AppendText("Contact US") 34 paragraph.ApplyStyle(BuiltinStyle.Heading2) 35 36 'Add paragraph 37 paragraph = section.AddParagraph() 38 39 'Insert an Emaillink 40 paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-
  • 4. iceblue.com", HyperlinkType.EMailLink) 41 42 'Save the file. 43 document.SaveToFile("Sample.doc") 44 45 'Launch the file. 46 System.Diagnostics.Process.Start("Sample.doc") 47 End Sub 48 End Module Screenshot after running the code above: More about Spire.Doc Download Spire.Doc Purchase Spire.Doc