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 columns, as follows:
How to do it...
Carry out the following steps in order to complete this recipe:
1. In the AOT, create a new job named
CreateWordTable
with the following code:static void CreateWordTable(Args _args) { TableId tableId; COM word; COM...