MERGEFIELD within HYPERLINK field issue: doesn't get replaced

Hi Support,

It seems like there is an issue when using MERGEFIELD fields when encapsulated into HYPERLINK fields.

We are using Aspose.Word to generate personalized PDF documents. Each document contains some dynamic URL’s (by dynamic, we mean personalized URL). We make use of the MailMerge.ExecuteWithRegions function.

The following “code” within a Word template works without any problem:

Unfortunately, the following “code” does not work:

Aspose.Word does not find/replace the MERGEFIELD encapsulated into the HYPERLINK field.

I suspect there must be an easy fix but I haven’t been able to find it within the documentation or the support forum.

Any help would be appreciated. In advance, thank you.

David De Maeyer


Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16378. Our product team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

For your information: version 17.11.0 is used for production and version 18.1.0 is used for testing. The issue can be reproduced with both versions. We did also try to place a bookmark just after the MERGEFIELD (workaround suggested on different support/forum pages).

David De Maeyer


Currently your issue is pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.


It seems this is not an issue. Please see these documents ( (17.6 KB)) and try running the following code.

private static DataTable GetDataTable()
    DataTable dataTable = new DataTable("Bus");

    dataTable.Columns.Add(new DataColumn("TestURL"));

    DataRow dataRow;
    for (int i = 1; i < 9; i++)

        dataRow = dataTable.NewRow();
        dataRow[0] = "" + i;


    return dataTable;

Document doc = new Document(MyDir + @"Mergefield in Hyperlink.docx");

doc.Save(MyDir + @"18.1.docx");

Thank you for your feedback. We were actually able to reproduce the issue with your code and your example files. Simply adding a regular MERGEFIELD field after the HYPERLINK filed, saving and closing immediately the document would “break” the encapsulated MERGEFIELD. This led us to believe there was an issue related to the way we had manipulated (in this case, modified) the Word file. We were able to fix the template and get both MERGFIELD fields to be properly displayed.


It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

A post was split to a new topic: Perform Word Mail Merge on MergeField Nested in Hyperlink Field | C# .NET