Template administrators Microsoft Word Working with variables in Microsoft Word

Working with variables in Microsoft Word

Published on: May 16, 2024
Edited on: November 28, 2024

This article explains the different types of variables, how they work, and how to create and use them in Microsoft Word with eformity.

What are variables?

Variables are dynamic elements that help automatically insert data into a document. They ensure that information is consistently and correctly placed, depending on the content and settings you choose. Variables are crucial for creating flexible and reusable documents.

Types of variables

There are seven different types of variables in eformity, each with specific uses:

  1. Text (and List)
  2. Date
  3. Yes/No
  4. Number (without comma)
  5. Number (with comma)
  6. Currency
  7. Image

N_1: Text (and List) variables

These variables allow you to insert a piece of text in multiple places within a document. You can also set a default value, which will be used if the user does not provide one. List variables enable users to select from a set of values.

N_2: Date variables

These variables insert dates in various formats. The default value is 'Today()', which represents the document's creation date. Date variables can be formatted as 1-1-2024, January 1, 2024, or 2024-01-01, among others. See the table below for all possible formats.

NameExample
Standaard1-1-2024 00:00:00
Longdatemonday 1 january 2024
Mediumdate1 january 2024
Shortdate1-1-2024
d MMMM yyyy1 january 2024
dd-MM-yyyy01-01-2024
d-M-yyyy1-1-2024
ddMMyyyy01012024
Yyyy-MM-dd2024-01-01
dddd d MMMMmonday 1 january
dddd d MMMM yyyymonday 1 january 2024
dddmo
ddddmonday
MMMMjanuary
yyyy2024

N_3: Yes/No variables

The Yes/No variable displays a checkbox in the dialog. The user can then choose between Yes (checked) or No (unchecked). You can then use this value to add or omit certain variables or other content in the template or text block. You do this by entering 'Linked Elements' in the dialog tab.

N_4, N_5: Number variables

There are two types of number variables: one without decimal places and one with decimal places. They are used to input numeric values, with the precision depending on your choice.

N_6: Currency variables

These variables are used to insert currency amounts into a document. Currency variables have various default formats, such as €21.50 or €21,50, with variations in how thousands and decimals are displayed. See the table below for all possible formats.

NameExample
Default€21,50
#,#0.00€21.50
#.#0,00€21,50
#.#0€21
#,#0€21
default (N0)€21
default (empty)€21

N_7: Image variables

These variables allow you to insert images at a specified location within the document. Ensure that the variable has enough space, for example by placing it in a separate line or table.

Creating variables

All different types of variables are added in the same way. The first thing you need to do is open the eformity sidebar in Microsoft Word. The sidebar will automatically open once you open Word.

Once you have opened the sidebar, you can edit the desired template. To do this, first select the template by clicking on it. Then, you can click on the pen icon next to the document name or on 'Edit' in the options menu.

Step 1: Add a new variable

The template will open for editing. The sidebar will look slightly different than usual. To add a new variable, click the plus icon. This icon is circled in the image below.

Step 2: Select a data type

Clicking on the plus icon opens a new element in the sidebar. In this element, you can select the data type for the new variable. The image below shows this new element visually.

Step 3: Fill out the General tab (required)

After selecting a data type, another new element will open in the sidebar. This new element contains three or four tabs. We will discuss each tab separately, starting with the 'General' tab.

The General tab is available for every variable type. Within the General tab, there are three different options. The table below shows the name and function of each option:

NameDescription
Name (required)A name is required for each type of variable. This field is for your reference to recognize the variable later. The name cannot contain spaces or special characters.
DescriptionYou can add a description to each variable. This description can be used as additional information for the user.
Place on DialogThis option determines if the variable will appear in the dialog. By default, the variable appears in the dialog. Turn off this option to remove the variable from the dialog.

Step 4: Fill out the Value tab

Like the General tab, the 'Value' tab is active for every data type. The Value tab contains different options for setting the value entered by the user. Below is how the Value tab looks when active.

The Value tab has five different options. Each option is explained in the table below:

NameDescription
Default value typeYou can choose from different value types: Default value, Value, Expression, Variable, and Datasource.
Default valueIf this option is set, this value will be used if the user does not provide a value (e.g., if the variable is not in the dialog).
Default formatThe default format option determines the format of the value entered by the user. The different formats are listed under 'Types of variables'.
Document PropertyYou can create and edit existing document properties by entering '@property' (in English, e.g., @author) in this field. The user's input will be added to the document property.
BookmarkIn addition to inserting variables through the sidebar by clicking the 'Execute' button, you can also add them at the location of a bookmark. Enter the relevant bookmark in this field.

Optional: Fill out the List tab

If you selected 'Text' as the data type, an additional 'List' tab will be available. Below are the different components of this tab explained:

N_1: Select a list source

When you click on the List tab, you can choose from three different sources:

NameDescription
TranslationAllows you to choose between different translations instead of just inserting one translation.
ListAllows you to add your own values from which the user can then choose.
DatasourceAllows you to use a Datasource for the list. First, choose a source from available data sources. Then select which value from the data source will be the display field, and finally, which value will be the key field.

N_2: Choose which value to use

After selecting a source and setting it up, specify which value to use. You can choose between 'Return the key value' and 'Return the value'.

N_3: Determine how to present choices

You can decide how to present choices to the user. There are four options: dropdown menu, editable list, selectable button, and checkbox. The table below provides more information about these options:

NameDescriptionExample
Dropdown menuAllows the user to select one option from the list. The choices are displayed in a dropdown menu.
Editable dropdown listAllows the user to select one option from the list or type their own value. The choices are displayed in a dropdown menu.
RadiobuttonAllows the user to select one option from the list. The choices are displayed with radio buttons.
CheckboxAllows the user to select multiple options from the list. The choices are displayed with checkboxes.

Stap 5: Fill out the Dialog tab

The final tab for creating a variable is 'Dialog'. The table below visually represents the Dialog tab.

The Dialog tab has three options, as explained in the table below. Additionally, there are fourth and fifth options that are variable-specific.

NameDescription
CaptionThe caption is shown in the dialog for users. If no caption is entered, the variable name is used.
OrderEnter a number to specify the order in the dialog. Higher numbers place the variable lower in the dialog.
RequiredSelect 'Required' if the variable must be entered or adjusted.
Is multilineAllows the user to add text longer than one line. This option is only available for text variables.
Linked controlsIn this field, you can enter other variables that should only be visible based on the value of the Yes/No variable. Enter the variable names here, separated by a ';' (e.g., 'variableName1;variableName2'). This option is only available for Yes/No variables.
Info icon

Tip!

Use steps of 10 for setting the order (e.g., 10, 20, 30, etc.). This way, you can easily insert a variable later without having to adjust all the steps.

Inserting variables into a document

Now that you know the different types of variables and how to create them within the sidebar of eformity, it’s time to use them in your document.

To insert a variable, first click on the spot in the document where you want the variable to appear. Then, double-click the desired variable to insert it.

Alternatively, you can insert a variable by selecting it and clicking the 'Play' icon. The image below shows how to do this.