Hyperlink is really one of the wonderful functions in Word document. You only need to use Ctrl+click , another page would appear automatically, which makes an amazing effect. Hyperlink can be used everywhere. From Word Document, you can create links to specific locations in files that are saved in the Office Excel (.xls) file format or the PowerPoint (.ppt) file format. With Spire .Doc, you can create hyperlinks to other documents, webpages or other locations within your current document. What is Spire Doc? How to operate Word Hyperlink in Spire.Doc using Visual Studio?
Spire Doc, as an MS word component, enables its users to perform a wide range of processing tasks directly. Without Microsoft Office Word, Spire Doc can effectively generate, read, write and modify Word document for .NET and Silverlight. Besides, it supports C#, VB.NET, ASP.NET ASP.NET MVC and Silverlight as well as Word 97, Word 2003, Word 2007 and Word 2010.
Procedure
First, create the Word Hyperlink project.
Open Visual Studio (2008 or later)—File—New Project—Visual C#—Windows Forms Application. Name Windows Forms Application Word Hyperlink (if you need to create a Visual Basic project, Windows Forms Application, you can name the project Word Hyperlink)—OK.
After build project Word Hyperlink in Form 1, you need to add a button in Form1.
Second, add reference.
Open Solution Explorer——Click project —Add Reference—Find "C:\Program Files\e-iceblue\Spire.Doc"(the default folder which you installed the Spire Doc in )— Double-click the folder Bin.
If the target framework of the project
Net 2.0, double-click folder NET2.0
or Net 3.5, double-click folder NET3.5
or Net 4.0, double-click folder NET4.0
Select assembly Spire Doc dll—Click OK
Third,view the method.
After you create the Project Word Hyperlink, double-click “button1”, you can see the cold view and the following method has been added automatically:
private void button1_Click(object sender, EventArgs e)
Spire Doc, as an MS word component, enables its users to perform a wide range of processing tasks directly. Without Microsoft Office Word, Spire Doc can effectively generate, read, write and modify Word document for .NET and Silverlight. Besides, it supports C#, VB.NET, ASP.NET ASP.NET MVC and Silverlight as well as Word 97, Word 2003, Word 2007 and Word 2010.
Procedure
First, create the Word Hyperlink project.
Open Visual Studio (2008 or later)—File—New Project—Visual C#—Windows Forms Application. Name Windows Forms Application Word Hyperlink (if you need to create a Visual Basic project, Windows Forms Application, you can name the project Word Hyperlink)—OK.
After build project Word Hyperlink in Form 1, you need to add a button in Form1.
Second, add reference.
Open Solution Explorer——Click project —Add Reference—Find "C:\Program Files\e-iceblue\Spire.Doc"(the default folder which you installed the Spire Doc in )— Double-click the folder Bin.
If the target framework of the project
Net 2.0, double-click folder NET2.0
or Net 3.5, double-click folder NET3.5
or Net 4.0, double-click folder NET4.0
Select assembly Spire Doc dll—Click OK
Third,view the method.
After you create the Project Word Hyperlink, double-click “button1”, you can see the cold view and the following method has been added automatically:
private void button1_Click(object sender, EventArgs e)
Fourth, add the following codes to the method.
C#
using Spire.Doc;
using Spire.Doc.Documents;
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
InsertHyberlink(document.AddSection());
//Save doc file.
document.SaveToFile("Sample.doc",FileFormat.Doc);
//Launching the MS Word file.
WordDocViewer("Sample.doc");
}
private void InsertHyberlink(Section section)
{
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("Spire.XLS for .NET \r\n e-iceblue company Ltd. 2002-2010 All rights reserverd");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendText("Home page");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
paragraph = section.AddParagraph();
paragraph.AppendText("Contact US");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendHyperlink("mailto:[email protected]", "[email protected]", HyperlinkType.EMailLink);
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
Finally, operate the project Word Hyperlink.
In Solution Explorer, right-click the project Word Hyperlink—Click Debug—Start new instance, you can see the opened window Form1—Click button 1, you can see there are two hyperlinks in the Spire.Doc document. Look at the picture 6.1:
In Solution Explorer, right-click the project Word Hyperlink—Click Debug—Start new instance, you can see the opened window Form1—Click button 1, you can see there are two hyperlinks in the Spire.Doc document. Look at the picture 6.1:
The magical effect of Word Hyperlink in Spire.Doc is distinctly displayed. It is out of words to explain it accurately. So only do it by yourself, can you realize that it is indeed convenient as well as miraculous. In Spire.Doc, many useful functions can be effectively and rapidly operated. That is why Spire.Doc enjoys great popularity in over sixty countries all over the world. Now let me introduce a more powerful componnet Spire. Office, which, as a compilation of Microsoft office component offered by e-iceblue, contains Spire.Doc, Spire.XLS, Spire.PDF andSpire.Data Export. Spire.Doc will be 20% off. It’s a great chance for you to purchase cheap quality with high quality, so never lost it. The detail information can be found in the following website:
Source