How to edit docx templates word document court report - rubyforgood/casa GitHub Wiki
Table of Contents generated with DocToc
Word document templates are handled by the gem sablon
Sablon looks for mergefields in word documents for instructions.
To make a mergefield go to insert>quick parts>field. This is in microsoft office 2007. I'm sure later versions have something similar.
Then this window pops up. Select "Mergefield" then click "Field Codes".
Sablon instructions go in this text box
To access mergefields easier, fields can be added to the quick access toolbar by right clicking it.
and it will appear in the menu top left
❗❗❗Heads Up❗❗❗
Editing merge field text surrounded by <<>>
does not change the instruction in the mergefield
It is possible to have an invisible mergefield containing no text at all
To toggle seeing actual mergefields text press alt
+ f9
Also
Sometimes syntax errors aren't detected by sablon and the document generated from the template comes out incorrectly. It's best to only add 1 or 2 instructions at a time then test.
Environment
Microsoft Office 2007 is the earliest version supporting .docx files