In complex templates, the balancing of
<<Else()>> commands with the matching
<<ForEach>> can become difficult.
The Template Painter
The Template Painter tool can be very useful for this. The Template Painter can be invoked either from the Common Tools menu (Word 2007) or the Template Author toolbar (Word 2003) or from the toolbar on the Template Author’s Toolkit (TAT).
The Template Painter will highlight matching start and end block commands (If and ForEach commands are known as block commands) with the same color, and at the same time format all the fillpoints with the font and color which can be set using the Define the font and colour of fillpoints button on the TAT (this feature in the TAT also enables you to change the colors that the Painter applies to the start and end block commands).
In addition, the Painter will notify you when there are missing or extra (floating) End commands. Floating End commands are highlighted with the text <========. The floating End command is not removed, because it might in fact be the correct command and an End earlier in the template might be the floating one.
Running a Template – the Debug command
When a template is run, XpressDox will check for missing and floating End commands as well as floating Else commands.
Wherever possible, the error message warning about one of these situations will give some context within the document where the relevant command is, so that you can find it easily and correct the situation.
But sometimes it’s not possible for XpressDox to provide a context. When this happens, XpressDox will recommend that you use the
<<Debug()>> command. When you put the Debug command somewhere (preferably right at the top) in the template, then if there is a floating End or Else command in the template after that Debug command, then XpressDox will highlight that floating command in the text of the merged document.
When there is a Debug command in a template, XpressDox will put a big ugly warning at the top of the merged document warning about the presence of the Debug command, so once there are no more floating commands, the Debug command should be removed.