Free Support Forum - aspose.com

Mergefields with hyperlinks

Hi, i am working on an very old project which is using Aspose.Word te merge data in a document.
There is a request to add hyperlinks to the merge fields.

The word template has the following construction:

For the «TableStart:tblOptions»«offProjects»«TableEnd:tblOptions» you will find with this letter the following:
«offProjects» is a list of 1 or more projects ( Project A, Project B, Project C ... )

In the code the follwing is done to fill a data table

strOfferedProjects = "Project A, Project B, Project C"

DataTable tblOptions = new DataTable();
tblOptions.Columns.Add("sysDate");
tblOptions.Columns.Add("offProjects");
tblOptions.Rows.Add(new object[] {DateTime.Now, strOfferedProjects});
cHeaderData.AddDataItem(tblOptions, "tblOptions");

To merge the data:

Document newDoc = new Document();
newDoc = new Document("Test.doc")

newDoc.MailMerge.MergeField += new MergeFieldEventHandler(SpecialFieldMerge);
newDoc.MailMerge.ExecuteWithRegions(sourceData);
newDoc.MailMerge.DeleteFields();

Is there a possiblity to change list of names to individual hyperlinks?

For example.
Name A --> www.gotonameA.nl
Name B --> www.gotonameB.nl

Any help is appriceated.

Sincerly,
Dirk Molman







This message was posted using Page2Forum from Mail Merge with Regions Explained - Aspose.Words for .NET

Hi Dirk,

Thanks for your inquiry.

I think you can use the same technique as described in this article here. In your case instead of using DocumentBuilder to insert a checkbox you will use the DocumentBuilder to insert a hyperlink via the InsertHyperlink method.

Also note that the code differs a little because you are using an older version and the newer versions use a new API for handlers. The basis of your code should be the same and you should beable to insert your code within the SpecialFieldMerge handler.

Thanks,