Creating a Word document with repeating elements

Microsoft Office Word documents created from Dynamics AX code, besides simple data output, can have more complex structures, such as a dynamic number of repeating elements. For example, a collection letter document can have a variable list of overdue invoices for different customers.

In this recipe, we will create a Word document with repeating elements. For this demonstration, we will display the contents of the LedgerParameters table in a dynamically generated Word table.

Getting ready

For this example, we need to prepare a new Word template and save it as a file named table.dotx. The template should contain one bookmark named TableName at the top, and one table beneath with a single row and two ...

Get Microsoft Dynamics AX 2012 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.