Microsoft Word: Using Document Properties as Variables

Microsoft Word: Using Document Properties as Variables

During a recent consultation, a client mentioned a common challenge many of us face with Microsoft Word. When preparing documents like contracts or reports, we often need to enter the same information, such as a client's name, in multiple places. Manually filling each field is not only tedious but also prone to errors, especially in longer documents. Instead of updating each occurrence by hand, we can use Microsoft Word's built‑in document properties to define variables. That way, we enter the data once, and Word automatically populates it throughout the document.


Creating Variables

Suppose we are working on the following service agreement template using Microsoft Word.

From the document, we can see that there are multiple areas we need to insert the client's name as denoted by the CLIENT_NAME placeholder. To create a variable for the client's name, navigate to File > Info > Properties.

Select Advanced Properties and we should be greeted with the Properties pop-up box.

Select the Custom tab and we should see a list of pre-defined properties.

For our case, we would like to create a custom variable for the client's name. Firstly, in the Name field, enter a name for the variable. Next, in the Type field, select the type of the variable. Lastly, in the Value field, enter the value of the variable. Once the form is populated, select Add to create the variable. In this example, I used "Client Name", "Text", and "John Doe" as the name, type and value respectively.

Once the variable has been added, select Ok to close the pop-up box. You may add more variables to your document properties at this juncture as well.

To use these variables in our document, we will need to insert them as fields at the designated locations. In our example, we will replace the CLIENT_NAME placeholder with our newly created variable. Click on or highlight the area to insert the variable. Navigate to Insert > Quick Parts.

Select Field... and we should be greeted with the Field pop-up box.

Firstly, in the Field names dropdown, select DocProperty. Next, in the Property dropdown, select the variable you would like to insert. Lastly, select Ok to insert the variable as a field. In this example, I selected the "Client Name" property to insert the client's name variable as a field.

From the screenshot above, we can now see that "John Doe" is now shown in the document. We can repeat this process to insert variables throughout the document where needed. In this example, I repeated the process to replace all CLIENT_NAME placeholders with the Client Name variable.

After everything has been configured and saved, it can then be copied and reused in the future with ease.


Updating Variables

Modifying the value of the variables across the document can be done in two simple steps. Open the Properties pop-up box detailed in the previous section. Double click on the variable we would like to modify, change the value in the Value field, and select Modify. In this example, I will change the value of Client Name from "John Doe" to "Jane Shmoe".

Now that we have updated the variable, we will need to update the document as well. Navigate back to the document, press Ctrl + A keys simultaneously on your keyboard to highlight the entire document and press F9 to update the document.

After updating the document, we can see that all instances of "John Doe" have been updated to "Jane Shmoe".


Summary

In conclusion, using Microsoft Word's document properties as variables simplifies the population of fields spread across long documents. If you would like assistance with leveraging IT to simplify business operations, feel free to get in touch with us using the "Contact Us" form on our main site, and our team will be happy to assist!