GenerateWordDoc(template.docx, "My Document", "tagName", [string])
where [string] is any text value
GenerateDocFromJSON( ) Usage
GenerateDocFromJSON(template.docx, "My Document", "{"tagName":"[value]"}")
where [value] is any text value
2. Conditionals
Usage in Template Doc
{#tagName}Show this sentence.{/tagName}
GenerateWordDoc( ) Usage
GenerateWordDoc(template.docx, "My Document", "tagName", [boolean])
where [boolean] is either true() or false()
GenerateDocFromJSON( ) Usage
GenerateDocFromJSON(template.docx, "My Document", "{"tagName":[boolean]}")
where [boolean] is either true or false
3. Loops
Usage in Template Doc
{#loopTag}
Inner loop text. {innerLoopVariable}
{/loopTag}
GenerateWordDoc( ) Usage
N/A (can’t be used for loops)
GenerateDocFromJSON( ) Usage
GenerateDocFromJSON(template.docx, "My Document", "{"loopTag":[{"innerLoopVariable": "[value1]"}, {"innerLoopVariable": "[value2]"}, {"innerLoopVariable": "[value3]"}]}")
where [value1], [value2], and [value3] are any text values
Examples
1. Without Loops
Template Doc
Below is a template doc that uses one placeholder tag (name) and one conditional tag (showPara).
Input Data
The data we want to use in this template is below:
Name
Show Paragraph
Name
Show Paragraph
1
Tommy
There are no rows in this table
Button Formula
We will use the GenerateWordDoc formula since we don’t need loops. The button setup should look like this:
Try It!
Click the “Generate Word Doc” button to generate the filled-in word doc and then click the Download Link to save and view it. Try changing the values in the
We will use the GenerateDocFromJSON formula since we need loops this time. There are a few ways to generate JSON in Coda. Whichever method you use, you will need to end up with a JSON string that looks like this for the template doc and input data above:
For this example, we’ve used the JSONify() and ListToText() formulas that are supplied in the Export to Word Pro pack to build the JSON. The complete formula looks like this:
The button setup for using the GenerateDocFromJSON() formula should look like this:
Try It!
Click the “Generate Word Doc” button to generate the filled-in word doc and then click the Download Link to save and view it. Try changing the values in the