We already have the format mapped, so we can download our Word document by selecting the Word node, going to ‘Attachments’ and then selecting ‘Open’:
Let’s open our Word document and ensure we have the ‘Developer’ tab enabled. If it’s not visible, you can activate it by navigating to ‘File’ > ‘Options’ > ‘Customize Ribbon’.
Now, select ‘Developer’ > ‘XML Mapping Pane’ and, in the drop-down menu, choose ‘Report’.
On the right, you should see all the elements from the format. Note that if you change the format and download the Word document without saving it, the new elements will not appear.
Let’s add a header:
Let’s give content to the header by adding elements from the XML Mapping pane. Right-click on the element and select ‘Insert’ > ‘Plain Text’.
Now we can change the design of the elements we are adding to the template. A trick I use is to add a letter before and after the inserted element. This helps because, with repeating elements, there’s a bug where the new formatting sometimes doesn’t get applied when creating the document. After applying the formatting, simply delete the letters.
Putting the elements inside a table helps keep it neat.
To insert the logo, select ‘Picture’.
Now we can go ahead and start the body.
And the lines, the lines will have a header and n rows. Let’s start with a table with two rows:
Now, let’s make sure a row doesn’t get split between two pages. Select the whole table, right-click, go to Table Properties, then the Row tab, and deselect ‘Allow row to break between pages’.
And let’s make sure the header repeats on each page; let’s select the header row secondary button, table properties, row and select ‘Repeat header row at the top of each page’.
Next, select the second row, the one where we’ll have the repetition, and insert the product list as ‘Repeating’.
Now we can insert the fields. Here is where we really need to add the mapped field between letters because if we change the formatting, it may not work well otherwise. The trick is to select ‘aClick or tap here...a
‘ and then apply the formatting (color, alignment, bold, etc.).
And of course, after adding the fields, we can remove the extra elements.
Now, let’s add the footer.
Let’s save our document and re-upload it. First, let’s delete our current template.
Let’s upload the new one:
On the previous screen, select the new template by clicking on the Word node in the format.
Then, let’s ‘Run’ our format, selecting an item with variants.
Okay, not bad 🙃. Apart from the design, there are a few things we could fix, which I will cover in the next and final post of this series. We’ll look at how to prevent Word from deleting the line breaks of the address and how to show a blank instead of ‘Click or tap here to enter text’ when there is no content in a field. Additionally, we will see how to convert the document to PDF.
Leave a Reply