1. Home
  2. Administrators
  3. Document templates
  4. Macros
  5. Formula macros in Word 365 templates

Formula macros in Word 365 templates

This Docuo Word template macro allows you to run a Javascript formula that returns a text to be included in the document.

Formula macros in Word templates are only available in Docuo Enterprise.

The formula definition is done in the Word document itself with the following syntax:

@DOCUO.FORMULA{[format] ,[single replacement] }

Insert here a Javascript formula that returns a text



Format: Optional parameter. Any text with the word formatting (font, size, etc) that you want to use when embedding the result of the formula in the document. If the formula fails (because it is misspelled for example), this text will also be used as a default replacement.

Single replacement: Optional parameter. If TRUE, the replacement occurs only once (the formula will not be recalculated each time labels are replaced). Default is FALSE so that each time labels are replaced the data is automatically updated.

In this example we use a formula macro so that the “Remarks” section of a document is filled with the text “Pay by bank transfer” if the invoice total exceeds 3,000 or “Pay cash” otherwise:

Invoice number:< @Properties:Code>
Client:< @Customer:Name>
Amount:< @Data:Total>

Observations: @DOCUO.FORMULA{ FORMAT }

if(< @Data:Total>> 3000)


return “Pay by bank transfer”




return “Pay cash”



As indicated by the FORMAT parameter, the replaced text will be bolded and italicized.

As the SINGLE REPLACEMENT parameter has been omitted, if the invoice amount changes, the formula will be recalculated when labels are replaced from Docuo.

Formula macros in Word templates allow you to create documents with smart content automatically without having to create additional fields with formulas in the document category itself, which contributes to a more optimized and simpler layout of data fields and better system performance.

Updated on 19 de April de 2022
Was this article helpful?

Related Articles