Create Word (DOCX) Documents

Uploading/Creating a DOCX

If you are using a DOCX file as the template (you uploaded a DOCX file), then you will want to use the same formatting for the fields as you do in our Builder ( {$Fieldname}, {$AnotherField}, etc). 

Make sure to use unique names for each field name. Do not use numbers on their own (eg '123') or include spaces, punctuation, special characters, or hyphens in the field names to ensure an easy integration process..

Click here to download an example Word document.


Updating your DOCX

If you need to make changes to your uploaded DOCX file, simply edit the file on your computer then re-upload it to Formstack Documents.  At this time, you cannot modify a DOCX file from inside Formstack Documents.

To get started, simply login and create a new document! If you are uploading a document, please make sure you are using a file with .docx extension.


Table Row Loops

If you're generating an invoice, you're probably looking to create a table that loops through each of the line items and prints them on a new row in the table.  No problem!  We've added a new "tablerow" tag that you can use and it tells our system to treat the table row as a loop.  The tag works exactly like a "foreach" loop, so all you need to do is use "tablerow" instead of "foreach" and we'll handle the rest.

Here's an example:


The data that you send through to a table row loop needs to be an array (ie and array of products) that can be easily looped through.  The part after the dot in the variable name is the individual property for that element in the array.


Spacing Issues

If you are experiencing issues with missing spaces in your merged documents, we've got a fix for you.  Inside Word, open up your template, then go to File > Options, then click on the Trust Center, and click the Trust Center Settings button.



In the Trust Center Settings, click the Privacy Options item on the left, then on the screen, you'll want to uncheck the option that says "Store random numbers to improve Combine accuracy".



Go ahead and save those settings, save your template, then upload to Formstack Documents!



Was this article helpful?
38 out of 56 found this helpful


  • jeremy,

    I have a form with bulleted and indented sections. Ican bullet but I cannot figure out how to indent to the second or third level.


  • Hi Darius,

    I have added the indent button to the editor.  Please clear your cache and try again for me.  Also, you don't have to build this document from scratch.  You can put the field placeholders in your Word document, then upload that document.


  • Every time I test merge a word document it always add the header and footer section, messing with the formatting, even though the original document doesn't have the header and footer sections when I uploaded.
  • Hi Alan, That's because we are adding the sample watermark to your document - which adds a header. If you have more questions, please create a ticket and we'll help from there!
  • Jeremy, when my Word document generates it seems to ignore page breaks. Is there anything special I need to do to make sure the page breaks are recognized? When I run it as a PDF it works perfectly and the pages are divided up as desired. Thanks!

  • Hi Clinton,

    Line breaks should work, but it depends how the data is being sent over to WebMerge. Can you submit a ticket with more details? Thanks!

  • Hi,

    I wonder if there is an option to export word doc in A4 size instead of the letter-size?

  • I would also like to know if there's a possibility to decide margins of the final word document through webmerge?

  • Minja are you using a Word document template? or the Document Builder. Both should be possible if you are using a Word template...

  • Hi Minja,

    Yes, if you use a Word document as your template, you can customize the page margins, page size, etc. Simply set those settings in your Word document and when we merge the template, those settings will stay.

    Thanks for helping Clinton!

  • Thanks for your reply. I'm using document builder. But I don't see where I should make these settings to get it right (neither in MS Word or in the document builder).

  • Hi Minja,

    I would suggest using a Word document as your template instead. The page margins are options within Word (under Layout)

  • Hi Jeremy,

    Is it also possible to merge images from Salesforce to the MS Word WM Template? I am trying to attach the profile photo's of contact record to the merge templates. Thanks.

  • Hi Cyrus,

    Unfortunately, we're not able to download files from Salesforce. You'll need to save the files in a service like Dropbox, then save the URL to the file in Salesforce. Sorry!

  • Hi Jeremy,

    Which fonts are supported for a docx ?

  • Hi Arlo,

    All fonts are supported in DOCX, but if you are exporting to a PDF, we need to install the fonts on our servers first. You can email the font files (We have the standard Windows fonts already installed) to support and we'll get them installed.

  • Hi jeremy,
    how can i use tablerow to send data into table that i added in docx file. I have array with data like $data['name'], $data['age'], $data['sex'], and i have fields in table name, age, sex. i sent data but it show blank fields, How can i use send this row? Any example will be appreciated.

  • How can we merge values for Checkbox in Docx file?

  • Hi Arslan,

    If you're sending JSON for example, it would look something like this:

    {"name":"John", "age":"32", "sex":"Male"},
    {"name":"Suzy", "age":"38", "sex":"Female"},
    {"name":"Sarah", "age":"25", "sex":"Female"}

    Then inside your document, your loop would be {tablerow from=$people item=data}

    For checkboxes, you have to do an if statement like this:

    {if $Gender == "Male"}[ X ]{else}[ ]{/if} Male
    {if $Gender == "Female"}[ X ]{else}[ ]{/if} Female

  • Thanks $_Jeremy, It works fine now :)

  • Can we still use {tableif} when importing a Word table?

  • @Nathan,

    Yes, you can use {tableif} and {tablerow} in your Word doc templates as well!


  • Can I upload a Word document and use it as the template for an email delivery rather than a PDF? I don't appear to have email as a delivery option after upload.

  • @Nathan,

    Yes, you can use Word as your output as well and send it via email. Please take another look for me :)

  • How to handle check boxes in word document? is there any specification to be followed

  • Hi Sharmila,

    Unfortunately, traditional checkboxes won't work, but you can do something like this with "if" statements:

    {if $gender == "Male"}[X]{else}[ ]{/if} Male
    {if $gender == "Female"}[X]{else}[ ]{/if} Female

  • Hi, I have successfully used the if/else to create 'checkboxes'.

    However, I am having a problem when I have more than one value coming through so want 'contains' rather than == so that I can put checkboxes for the values in different cells of a table.

    "type_of_scour_valve_1_3": "worn_bearing,correct_meshing,pinion"

    I've tried a few things with index and in but I get an error about a space in my merge field.

    What is the best way to do this? Thanks.

  • To do a "contains" search, you'll want to use stristr() like this:

    {if stristr($gender, "Male")}[X]{else}[ ]{/if} Male

  • Great, that works, thank you!

  • Hello Jeremy,
    How can I display pictures (not the related links) into a Word template, knowing those pictures are coming from a form generated Through formstack

    Many thanks for your help,



Please sign in to leave a comment.