Creating a Word document using automation objects
Microsoft Word exposes its object model through COM automation the same way as Excel. The following example demonstrates how to export a dataset into a Word document via Automation variables. We will create a document containing a table and export a list of items in the Where-used report into the table.
The Where-used report is a list of assembled items, which includes the given item as a component in their bill of materials.
How to do it...
Open C/SIDE page designer and create a list page. In the Table field, select the Item table. Run the page wizard and include two table fields in the page: No. and Description.
After completing the wizard, open the page action designer and insert an
Export
action button that will be used to trigger document creation. In theExport - OnAction
C/AL trigger insert one line of code:CreateWordDocument("No.");
In C/AL globals, declare the
CreateWordDocument
function just referenced in Step 2. One parameter...