SlideShare una empresa de 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

Más contenido relacionado

Más de 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
 

Más 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

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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 WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 RobisonAnna Loughnan Colquhoun
 
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 MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

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