SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
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 interpreternaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Kürzlich hochgeladen (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

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