SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais de 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
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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