We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding a Link to Word Document Programmatically

I would like to add a link to a Word Document using Aspose.Words. I would like a relative link to a document that will be stored at the same level in the directory. How can this be done?
This would be the equivalent of taking the following steps in word:
Then, in the object dialog (see attachment)
Select Create from File tab
Select Link to File
Select Display as Icon
Your assistance is appreciated.

Thanks for your inquiry. Unfortunately there is not way to insert embedded or linked objects. But you can try inserting LINK field. See the following code example:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField("LINK Word.Document.8 \"C:\\\\Temp\\\\in.doc\" \"\" \\a \\f 0 \\p", "doc");

But note that Aspose.Words doesn’t update this field so you should update fields inside the document manually (ctrl+A and F9). Also you can use macro to update fields. See the following link to learn more.
Best regards.

Thanks for your prompt reply Alexey. What about adding a simple, relative HREF to the document? For example: Another Document. I have seen this in a .mht word file, could I reproduce this with a DocumentBuilder?

Thanks for your inquiry. You can try using the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Best regards.